Had Practicals
Had Practicals
CERTIFICATE
The journal work is the original study work that has been duly
approved in the year 2021-2022 by the undersigned.
Table of Contents
Sr. Name of the Practical Page Date of Signature of
no.
No. Completion the Subject
Incharge
ANGULAR JS PRACTICALS
Page | 2
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Android Studio
12. Display dialog box and with the use of 57-60 16-08-21
intents invoke a built in application of
calling a Phone number
Page | 3
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 1
Aim : Data Binding- Simple script program to get the Name of the User.
Theory: Data binding automatically keeps your page up-to-date based on your
application’s state. You can use data binding to specify things such as source of an
image, the state of a button or data for a particular user.
Code :
<!DOCTYPE html>
<html>
<head>
<title>Practical 1</title>
<script src="angular.min.js"></script>
</head>
<body>
<div ng-app="">
<p> Enter First Name :<input type="text" ng-model="first"></p>
<p>Enter Last Name : <input type="text" ng-model="last"></p>
<h2>Student Details</h2>
</div>
</body>
</html>
Output :
Page | 4
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 2
Scope
1. Aim: Cars in array
Theory: The scope is the binding part between the HTML (view) and the
JavaScript (controller). The scope is an object with the available properties and
methods. The scope is available for both the view and the controller.
Code:
Output:
Page | 5
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
Output:
Page | 6
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 3
Controllers
1. Aim: Root scope
Theory: All applications have a $rootScope which is the scope created on the HTML
element that contains the ng-app directive. The rootScope is available in the entire
application. If a variable has the same name in both the current scope and in the
rootScope, the application uses the one in the current scope.
Code:
Output:
Page | 7
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
Output:
Page | 8
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 4
Aim: Filters-Birthday Party Invite
Theory: Filters are used to modify the data. They can be clubbed in
expression or directives using pipe (|) character
Code:
Page | 9
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 10
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 5
Aim: Design a Page - Fruit shop that has a Click Event added to an
image and MouseOver Event.
Theory: The AngularJS has a set of Event Directives that can be used to
set custom behavior when several types of events are triggered. Ng-click
event set a custom behavior for click event, the event is triggered when
the mouse is clicked. Ng-MouseOver event is used to execute or raise
custom events / functions whenever mouse cursor hover on html elements.
Code:
Page | 11
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 12
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 13
NAME: VANSH NAGDA ROLL NO: 381 CLASS: SYIT SUB: HAD
PRACTICAL – 6
Aim: Create a form with validation – Sports Turf
Theory: Forms in AngularJS provides data-binding and validation of input
controls. Required attribute used to specify that the input field must be filled out. E-
mail type used to specify the that the value must be an e-mail.
Code:
Page | 14
NAME: VANSH NAGDA ROLL NO: 381 CLASS: SYIT SUB: HAD
Page | 15
NAME: VANSH NAGDA ROLL NO: 381 CLASS: SYIT SUB: HAD
Output:
Page | 16
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 7
1. Aim: Http
Code:
Output:
Page | 17
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
Output:
Page | 18
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
3. Aim: Animation
Theory: An animation is when the transformation of an HTML element
gives you an illusion of motion. To make your applications ready for
animations, you must include the AngularJS Animate library.
Code:
Output:
Page | 19
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 8
1. Aim: Checkbox
Step 3: cd angular-material-checkbox-example
Step 4: ng add @angular/material
Page | 20
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatCheckboxModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
Page | 21
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
app.component.ts
interface Movie {
name: string;
selected: boolean;
disabled: boolean;
movieCollection?: Movie[];
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
constructor() { }
movies: Movie = {
name: 'Dynamic Movie List',
selected: false,
disabled: false,
movieCollection: [
{ name: 'Black Panther', selected: false, disabled
: false },
{ name: 'Avengers: Endgame', selected: false, disa
bled: false },
{ name: 'Mission: Impossible -
Fallout', selected: false, disabled: false },
{ name: 'Spider-Man: Into the Spider-
Verse', selected: false, disabled: false },
{ name: 'Mad Max: Fury Road', selected: false, dis
abled: false },
Page | 22
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
app.component.html
Output:
Page | 23
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Step 2: cd angular-material-copy-to-clipboard-demo
Step 3: ng add @angular/material
app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
Page | 24
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
ClipboardModule
],
providers: [],
bootstrap: [AppComponent]
})
app.component.html
app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
Page | 25
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 26
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Step 2: cd ng-demo-app
Step 3: npm install bootstrap
Step 4: npm install ngx-image-cropper
angular.json
"styles": [
"src/styles.scss",
"node_modules/bootstrap/dist/css/bootstrap
.min.css"
],
app.module.ts
Page | 27
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
ImageCropperModule
],
providers: [],
bootstrap: [AppComponent]
})
app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
Page | 28
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
imgLoad() {
// display cropper tool
}
initCropper() {
// init cropper
}
imgFailed() {
// error msg
}
}
app.component.ts
<div class="col-md-12">
<input type="file" (change)="onFileChange($event)" /
>
</div>
<div class="col-md-8">
<image-cropper
[imageChangedEvent]="imgChangeEvt"
[maintainAspectRatio]="true"
[aspectRatio]="4 / 4"
[resizeToWidth]="256"
format="png"
(imageCropped)="cropImg($event)"
(imageLoaded)="imgLoad()"
(cropperReady)="initCropper()"
Page | 29
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
(loadImageFailed)="imgFailed()">
</image-cropper>
</div>
<div class="col-md-4">
<h6>Image Preview</h6>
<img [src]="cropImgPreview" />
</div>
</div>
Output:
Page | 30
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Step 2: cd angualr-stripe-example
Go to stripe website https://stripe.com/en-in
Register to create a stripe developer account
Copy the publishable key from dashboard
app.component.ts
@Component({
Page | 31
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
paymentHandler:any = null;
constructor() { }
ngOnInit() {
this.invokeStripe();
}
makePayment(amount: number) {
const paymentHandler = (<any>window).StripeCheckout.
configure({
key: 'pk_test_51JRXSjSIuPAxMrnqtYz1JfnlZRZNGpjbPaU
31OokCa0w42vVu3ZP5vDE9LbYDPsruqnG8cDlUOSDxmGc6lJ07tpn00V
k4M9xl6',
locale: 'auto',
token: function (stripeToken: any) {
console.log(stripeToken)
alert('Stripe token generated!');
}
});
paymentHandler.open({
name: 'Positronx',
description: '3 widgets',
amount: amount * 100
Page | 32
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
});
}
invokeStripe() {
if(!window.document.getElementById('stripe-
script')) {
const script = window.document.createElement("scri
pt");
script.id = "stripe-script";
script.type = "text/javascript";
script.src = "https://checkout.stripe.com/checkout
.js";
script.onload = () => {
this.paymentHandler = (<any>window).StripeChecko
ut.configure({
key: 'pk_test_51JRXSjSIuPAxMrnqtYz1JfnlZRZNGpj
bPaU31OokCa0w42vVu3ZP5vDE9LbYDPsruqnG8cDlUOSDxmGc6lJ07tp
n00Vk4M9xl6',
locale: 'auto',
token: function (stripeToken: any) {
console.log(stripeToken)
alert('Payment has been successfull!');
}
});
}
window.document.body.appendChild(script);
}
}
app.component.html
<div class="container">
Page | 33
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 34
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
VANSH
Page | 35
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
angular.json
"styles": [
"src/styles.scss",
"node_modules/sweetalert2/src/sweetalert2.
scss"
],
app.component.ts
Page | 36
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
ngOnInit(){
console.log('Life Cyle Hook with spontaneous respons
e.');
}
tinyAlert(){
Swal.fire('Hey there!');
}
successNotification(){
Swal.fire('Hi', 'We have been informed!', 'success')
}
alertConfirmation(){
Swal.fire({
title: 'Are you sure?',
text: 'This process is irreversible.',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, go ahead.',
cancelButtonText: 'No, let me think'
}).then((result) => {
if (result.value) {
Page | 37
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Swal.fire(
'Removed!',
'Product removed successfully.',
'success'
)
} else if (result.dismiss === Swal.DismissReason.c
ancel) {
Swal.fire(
'Cancelled',
'Product still in our database.)',
'error'
)
}
})
}
}
app.component.html
Page | 38
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 39
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 9
Page | 40
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 41
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
8) Then to start running the ionic web page on the server type ionic serve:
Page | 42
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 43
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 44
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
MainActivity.java
package com.example.my_app;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
Page | 45
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 46
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
}
}
if (R.equals("Non-Jain")){
if (checkP.isChecked()){
total = total + 200;
}
if (checkB.isChecked()){
total = total + 150;
}
if (checkS.isChecked()){
total = total + 100;
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.my_app.MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="12dp"
android:layout_marginBottom="23dp">
<EditText
android:layout_width="316dp"
android:layout_height="wrap_content"
android:id="@+id/edtName"
android:hint="Name"
android:layout_weight="0.15" />
<EditText
android:layout_width="315dp"
android:layout_height="wrap_content"
android:id="@+id/edtNumber"
android:hint="Mob."
android:layout_weight="0.13" />
<RadioGroup
android:id="@+id/radioG"
android:layout_width="match_parent"
Page | 47
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
android:layout_height="wrap_content"
android:weightSum="1">
<RadioButton
android:id="@+id/radioV"
android:layout_width="wrap_content"
android:layout_height="49dp"
android:layout_weight="0.24"
android:checked="false"
android:text="Veg"
android:textSize="20dp" />
<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_weight="0.11"
android:checked="false"
android:text="Non-Veg"
android:textSize="20dp" />
<RadioButton
android:id="@+id/radioNV"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_weight="0.11"
android:checked="false"
android:text="Jain"
android:textSize="20dp" />
<RadioButton
android:id="@+id/radioNVv"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_weight="0.11"
android:checked="false"
android:text="Non-Jain"
android:textSize="20dp" />
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Menu:"
android:id="@+id/textView"
android:paddingTop="10dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="55dp"
android:text="Pizza "
android:id="@+id/checkP"
android:checked="false"
android:layout_weight="0.09"
android:textSize="20dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
Page | 48
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
android:paddingLeft="20dp"
android:text="Rs = 200"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="55dp"
android:text="Burger"
android:id="@+id/checkB"
android:checked="false"
android:layout_weight="0.20"
android:textSize="20dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="20dp"
android:text="Rs = 150"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="55dp"
android:text="Sandwich"
android:id="@+id/checkS"
android:checked="false"
android:layout_weight="0.09"
android:textSize="20dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="20dp"
android:text="Rs=100"
android:textSize="20dp" />
</LinearLayout>
<Button
android:layout_width="124dp"
android:layout_height="wrap_content"
android:text="Order"
android:id="@+id/butOrder"
android:textSize="20dp" />
</LinearLayout>
</RelativeLayout>
Page | 49
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 50
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 51
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent"
tools:context="com.example.custom_styles.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
style="@style/dgstyle"/>
</LinearLayout>
Styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorprimary</item>
<item name="colorPrimaryDark">@color/colorprimarydark</item>
<item name="colorAccent">@color/coloraccent</item>
</style>
<style name="dgstyle">
<item name ="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:typeface">monospace</item>
<item name="android:background">#260068</item>
<item name="android:textSize">12pt</item>
<item name="android:textColor">#ffffff</item>/>
</style>
</resources>
Page | 52
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 53
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 11
Aim: Autocomplete text:
Theory:
Page | 54
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
MainActivity.java
package com.example.new_app;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//initiate an auto complete text view
AutoCompleteTextView simpleAutoCompleteTextView =
(AutoCompleteTextView) findViewById(R.id.simpleAutoCompleteTextView);
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, countryNameList);
simpleAutoCompleteTextView.setAdapter(adapter);
simpleAutoCompleteTextView.setThreshold(1);//start searching from 1
character
simpleAutoCompleteTextView.setAdapter(adapter); //set the adapter
for displaying country name list
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.new_app.MainActivity">
<AutoCompleteTextView
android:id="@+id/simpleAutoCompleteTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000"
android:hint="Enter Country Name Here"
android:padding="15dp"
android:textColor="@color/white"
Page | 55
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
android:textColorHint="#fff"
android:textStyle="bold|italic" />
</LinearLayout>
Output:
Page | 56
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 12
Page | 57
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.call2.MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="104dp"
android:ems="10"
android:hint="Number"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="84dp"
tools:layout_editor_absoluteY="55dp" />
<Button
android:id="@+id/button"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginTop="53dp"
android:background="@android:drawable/presence_online"
android:text="Call"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="137dp" />
</RelativeLayout>
Page | 58
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
MainActivity.java
package com.example.call2;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1=(Button)findViewById(R.id.button);
final EditText e1=(EditText)findViewById(R.id.editText);
b1.setOnClickListener(new View.OnClickListener() {
@Override
});
a.setNegativeButton("no",new
DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
a.create().show();
}
});
}
}
Page | 59
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 60
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 13
Aim: Device Camera
Theory:
Page | 61
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
MainActivity.java
package com.example.camera1;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
Page | 62
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Take a Photo" >
</Button>
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/button1"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" >
</ImageView>
</RelativeLayout>
Page | 63
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 64
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 14
Aim: Gesture Recognition:
Theory:
Page | 65
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:
MainActivity.java
package com.example.common_gesture;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GestureDetectorCompat;
t1 = (TextView)findViewById(R.id.t1);
this.gDetector = new GestureDetectorCompat(this,this);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
this.gDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
@Override
public boolean onDown(MotionEvent event) {
t1.setText ("onDown");
return true;
}
@Override
public void onShowPress(MotionEvent motionEvent) {
t1.setText("onShowPress");
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2, float
velocityX, float velocity){
t1.setText("onFling");
return true;
}
@Override
public void onLongPress(MotionEvent event) {t1.setText("onLongPres");}
@Override
public boolean onScroll(MotionEvent el, MotionEvent e2, float
distanceX, float distanceY){
t1.setText("onScroll");
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent event){
t1.setText("onSingleTapUp");
return true;
} Page | 66
}
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.common_gesture.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/t1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="0.433"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="232dp"/>
</RelativeLayout>
Page | 67
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:
Page | 68
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 15
GPS LOCATION
THEORY:
Page | 69
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Code:-
Activity_main.xml
Page | 70
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
MainActivity.java
Page | 71
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 72
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:-
Page | 73
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
PRACTICAL – 16
Aim: Sending E-Mail
Theory:
Page | 74
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
CODE:-
activity_main.xml
Page | 75
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Page | 76
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
MainActivity.java
Page | 77
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT
Output:-
Page | 78