[go: up one dir, main page]

0% found this document useful (0 votes)
90 views78 pages

Had Practicals

The document is a certificate for a student named Vansh Dilip Nagda who completed practical works for the course Hybrid Mobile Application Development-I at Nagindas Khandwala College of Commerce, Arts & Management Studies. The certificate is signed by the external examiner and subject in-charge, and includes the student's name, roll number, program, and semester. The certificate certifies that the journal work submitted by the student for partial fulfillment of the third semester of BSc IT during the 2021-2022 academic year is original work that was approved that year.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views78 pages

Had Practicals

The document is a certificate for a student named Vansh Dilip Nagda who completed practical works for the course Hybrid Mobile Application Development-I at Nagindas Khandwala College of Commerce, Arts & Management Studies. The certificate is signed by the external examiner and subject in-charge, and includes the student's name, roll number, program, and semester. The certificate certifies that the journal work submitted by the student for partial fulfillment of the third semester of BSc IT during the 2021-2022 academic year is original work that was approved that year.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

MALAD KANDIVALI EDUCATION SOCIETY’S

NAGINDAS KHANDWALA COLLEGE OF COMMERCE,


ARTS & MANAGEMENT STUDIES & SHANTABEN NAGINDAS
KHANDWALA COLLEGE OF SCIENCE
MALAD [W], MUMBAI – 64
(AUTONOMOUS)

(Reaccredited ‘A’ Grade by NAAC)


(AFFILIATED TO UNIVERSITY OF MUMBAI)
(ISO 9001:2015)

CERTIFICATE

Name: Mr.: Vansh Dilip Nagda

Roll No: 381 Programmed: BSc IT Semester: III

This is certified to be a bonfire record of practical works done by


the above student in the college laboratory for the course Hybrid
Mobile Application Development-I(Course Code:2136UISMD)
for the partial fulfillment of Third Semester of BSc IT during the
academic year 2021-2022.

The journal work is the original study work that has been duly
approved in the year 2021-2022 by the undersigned.

External Examiner Subject-In-Charge


(Ms.Elizabeth leah George)

Date of Examination: (College Stamp)


NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

Table of Contents
Sr. Name of the Practical Page Date of Signature of
no.
No. Completion the Subject
Incharge

ANGULAR JS PRACTICALS

Data Binding- Write the Script to get the 4 7-07-21


name of the User
1.

2. Angular Js- Using Scope 5-6 12-07-21


a. Cars in an Array
b. Colours in List

3. Controllers - Root Scope, Scope Colours 7-8 14-07-21

4. Filters - Birthday Party Invite (Use Filters) 9-10 19-07-21


Uppercase, Lowercase, Currency, Date
Friend List

5. Design a Page - Fruit Shop that has a 11-13 20-07-21


Click Event added to an Image and
MouseOver Event

6. Create a Form with Validation for 14-16 26-07-21


Booking a Football Turf

7. Write an AngularJS program to do the 17-19 27-07-21


following:
1) Http
2) Calendar Table
3) Animation

Page | 2
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

8. Angular Js Advanced Practicals 20-39 02-08-21


1. CheckBox
2. Copy the Text
3. Crop Image
4. Stripe card checkout payment
5. Alert Message

9. Installation of Ionic Practical 40-43 04-08-21

Android Studio

10. Android Custom Styles and Layout 44-53 09-08-21


1.Create a Food App with the layouts
2. create your own Custom Styles

11. Implement an application for 54-56 11-08-21


AutotextComplete for different countries

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

13. Android Device Camera 61-64 17-08-21

14 Implementing Common Gesture Detection 65-68 18-08-21

15 Create an android application to displayGPS 69-73 23-08-21


Coordinates.

16 Create and Android Application to send an 74-78 24-08-21


E-mail using Intent

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>

<p>First Name : <span ng-bind="first"></span></p>


<p>Last Name : <span ng-bind="last"></span></p>

</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

2. Aim: Colours in List


Theory: The ng-repeat directive repeats a set of HTML, a given number of
times. The set of HTML will be repeated once per item in a collection. The
collection must be an array or an object

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

2) Aim: Scope colours


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 | 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

Theory: $http is an AngularJS service for reading data from remote


servers.get() method used to fetch the data from a server

Code:

Output:

Page | 17
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

2. Aim: Calendar Table


Theory: The ng-repeat directive repeats a set of HTML, a given number of
times. The set of HTML will be repeated once per item in a collection. The
collection must be an array or an object.

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 1: Open command prompt and install npm install –g @angular/cli


Step 2: ng new angular-material-checkbox-example

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

import { BrowserModule } from '@angular/platform-


browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';


import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platfo
rm-browser/animations';

import { MatCheckboxModule } from '@angular/material/che


ckbox';
import { FormsModule } from '@angular/forms';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatCheckboxModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})

export class AppModule { }

Page | 21
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

app.component.ts

import { Component } from '@angular/core';

interface Movie {
name: string;
selected: boolean;
disabled: boolean;
movieCollection?: Movie[];
}

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})

export class AppComponent {

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

{ name: 'Wonder Woman', selected: false, disabled:


false }
]
};

app.component.html

<div *ngFor="let data of movies.movieCollection">


<mat-checkbox>
{{data.name}}
</mat-checkbox>
</div>

Output:

2. Aim: Copy the text


Step 1: ng new angular-material-copy-to-clipboard-demo

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

import { NgModule } from '@angular/core';


import { BrowserModule } from '@angular/platform-
browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platfo
rm-browser/animations';
import { FormsModule } from '@angular/forms';
import { ClipboardModule } from '@angular/cdk/clipboard'
;

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,

Page | 24
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
ClipboardModule
],
providers: [],
bootstrap: [AppComponent]
})

export class AppModule { }

app.component.html

<button [cdkCopyToClipboard]="copyClipText" [cdkCopyToCl


ipboardAttempts]="7">Copy</button>

app.component.ts

import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})

export class AppComponent {


title(title: any) {
throw new Error('Method not implemented.');
}

copyClipText = 'Hello, Text is copied!';

Page | 25
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

Output:

3. Aim: Crop Image


Step 1: ng new ng-demo-app

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

import { NgModule } from '@angular/core';


import { BrowserModule } from '@angular/platform-
browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { ImageCropperModule } from 'ngx-image-cropper';

Page | 27
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
ImageCropperModule
],
providers: [],
bootstrap: [AppComponent]
})

export class AppModule { }

app.component.ts

import { Component } from '@angular/core';


import { ImageCroppedEvent } from 'ngx-image-cropper';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})

export class AppComponent {

imgChangeEvt: any = '';


cropImgPreview: any = '';

onFileChange(event: any): void {


this.imgChangeEvt = event;
}
cropImg(e: ImageCroppedEvent) {
this.cropImgPreview = e.base64;

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="container mt-5 text-center">

<h3 class="mb-5">Angular Image Crop Example</h3>

<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

4. Aim: Stripe card checkout payment


Step 1: ng new angualr-stripe-example

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

Paste the key on app.component.ts file at key value

app.component.ts

import { Component } from '@angular/core';

@Component({

Page | 31
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})

export class AppComponent {


title(title: any) {
throw new Error('Method not implemented.');
}

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

<h2 class="mt-5 mb-


4">Angular Stripe Checkout Example</h2>

<div class="col-md-5 mb-2">


<button (click)="makePayment(15)" class="btn btn-
danger btn-block">Pay $15</button>
</div>
<div class="col-md-5 mb-2">
<button (click)="makePayment(25)" class="btn btn-
primary btn-block">Pay $25</button>
</div>
<div class="col-md-5">
<button (click)="makePayment(35)" class="btn btn-
success btn-block">Pay $35</button>
</div>
</div>

Output:

Page | 34
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

VANSH

5. Aim: Alert message


Step 1: ng new angular-sweetalert-demo

Page | 35
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

Step 2: cd ng new angular-sweetalert-demo


Step 3: npm i sweetalert2

angular.json

"styles": [
"src/styles.scss",
"node_modules/sweetalert2/src/sweetalert2.
scss"
],

app.component.ts

import { Component, OnInit } from '@angular/core';


import Swal from 'sweetalert2';

Page | 36
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})

export class AppComponent implements OnInit {


title(title: any) {
throw new Error('Method not implemented.');
}

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

<button (click)="tinyAlert()">Simple Notification</butto


n>

<button (click)="successNotification()">Sucess Notificat


ion</button>

<button (click)="alertConfirmation()">Show me Confirmati


on</button>

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

Aim: Installation of Ionic


1) open command prompt as administrator

2) Run npm install -g ionic:

Page | 40
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

3) Create a folder for your ionic project by running md:

4) Navigate to the folder by running cd:

5) To create an ionic app run ionic start:

Page | 41
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

6) Then it will ask to choose a framework so choose Angular JS:

7) Then it will ask to select starter template so choose tabs:

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

ANDROID PRACTICAL LIST


PRACTICAL – 10

1. Aim: Food order app


Theory:

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;

public class MainActivity extends AppCompatActivity implements


View.OnClickListener {
EditText edtName, edtNumber;

Page | 45
NAME: VANSH DILIP NAGDA ROLL NO: 381 CLASS: SYIT

RadioButton radioV, radioNV, RadioBut,r1,r2;


CheckBox checkP, checkB, checkS;
Button butOrder;
RadioGroup radioG;
TextView OrderDetails2, OrderDetails;
int total = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtName = findViewById(R.id.edtName);
edtNumber = findViewById(R.id.edtNumber);
r1= findViewById(R.id.r1);
r2= findViewById(R.id.radioNVv);
radioV = findViewById(R.id.radioV);
radioNV = findViewById(R.id.radioNV);
radioG = findViewById(R.id.radioG);
checkP = (CheckBox)findViewById(R.id.checkP);
checkB = (CheckBox)findViewById(R.id.checkB);
checkS = (CheckBox)findViewById(R.id.checkS);
butOrder = (Button)findViewById(R.id.butOrder);
butOrder.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == butOrder){
int SelectedID = radioG.getCheckedRadioButtonId();
RadioBut = (RadioButton)findViewById(SelectedID);
String R = RadioBut.getText().toString();
if (R.equals("Veg")){
if (checkP.isChecked()){
total = total + 100;
}
if (checkB.isChecked()){

total = total + 100;


}
if (checkS.isChecked()){
total = total + 50;
}
}
if (R.equals("Non-Veg")){
if (checkP.isChecked()){
total = total + 200;
}
if (checkB.isChecked()){
total = total + 150;
}
if (checkS.isChecked()){
total = total + 100;
}
}
if (R.equals("Jain")){
if (checkP.isChecked()){
total = total + 200;
}
if (checkB.isChecked()){
total = total + 150;
}
if (checkS.isChecked()){
total = total + 100;

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;
}
}

String Summary = "Name: " +edtName.getText()+ "\nPhone:


"+edtNumber.getText()+"\nType: "+RadioBut.getText().toString()+"\nTotal:
"+total;
total = 0;
Toast.makeText(this,Summary, Toast.LENGTH_LONG).show();
checkP.setChecked(false);
checkB.setChecked(false);
checkS.setChecked(false);
}
}
}

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

2. Aim: Custom styles:


Theory:

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;

public class MainActivity extends AppCompatActivity {

String[] countryNameList = {"India", "China", "Australia", "New


Zealand", "England", "Pakistan"};

@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

Aim: Intent Call a Number


Theory:

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;

public class MainActivity extends 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

public void onClick(View v) {


AlertDialog.Builder a=new
AlertDialog.Builder(MainActivity.this);
a.setMessage("do you want to call ?");
a.setPositiveButton("Yes", new
DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
Intent i=new
Intent(Intent.ACTION_DIAL,Uri.parse("tel:91"+e1.getText()));
startActivity(i);}

});
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;

public class MainActivity extends Activity {


private static final int CAMERA_REQUEST = 1888;
ImageView imageView;
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView = (ImageView) this.findViewById(R.id.imageView1);


Button photoButton = (Button) this.findViewById(R.id.button1);

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);
}
});
}

protected void onActivityResult(int requestCode, int resultCode, Intent


data) {
if (requestCode == CAMERA_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
}

@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;

public class MainActivity extends AppCompatActivity implements


GestureDetector.OnGestureListener{
private TextView t1;
private GestureDetectorCompat gDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

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

Aim: Create an android application to display GPS Coordinates.

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

You might also like