0% found this document useful (0 votes)
21 views

App Development Manual

App dev
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)
21 views

App Development Manual

App dev
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/ 54

Ex.

no: 1 BMI CALCULATOR


Date:- A Cross Platform Application using React Native

AIM:
To write a React Native Application which perform BMI Calculation using Cross Platform
App Development in Windows.
ALGORITHM :
1. Nodejs V.14 or greater and JDK 11 or higher is required.
2. Install Chocolatey for window which ensure Node LTS and JDK 11 was properly installed by
pressing Windows button -> cmd.exe (run as administrator) -> paste the following path

C:\WINDOWS\system32>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell
.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" &&
SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

3. Check Chocolatey was installed properly verify at: ‘C:\ ProgramData\ chocolatey\ bin\
choco.exe’
4. Install Nodejs and JDK with code: choco install –y nodejs-lts openjdk11
5. Install AndroidStudio with Android SDK tools & platform with Virtual Devices.
5.1 Install stable SDK Platform either Android 12.0 or Android 13.0 version
5.2 Install Intel x86 Atom_64 System Image in SDK package.
5.3 Install SDK Build tools with either 31.00 or 33.00 version
6. Set the Environmental Variable:
ANDROID_HOME: C:\Users\ System_Name\ AppData\Local\Android\Sdk>
7. Start PowerShell and type: C:\Users\ System_Name> Get ChildItem –path Env:\ to check
the Environmental variable was set.
8. Set the Environmental at system variable:
Edit the path by adding new: C:\Users\ System_Name\ AppData\ Local\ Android\ Sdk\
platform-tools>
9. Setting up Virtual Device at Virtual Device Manager at Android Studio by selecting any
virtual device and SDK version.
10. Create a Reactive Native projects kindly type the following at the command line :
C:\projects\reactnative>npx react-native init BMICALC
11. To type the code & run it at command prompt :
11.1 Type as C:\projects\reactnative>cd BMICALC
11.2 Check the directory with: C:\projects\reactnative\BMICALC\dir
11.3 To run at Visual studio code type: C:\projects\reactnative\BMICALC\code .
11.4 Type the BMI Calculator code at App.js file
11.5 To run the project type: C:\projects\reactnative\BMICALC>npm start
11.6 To run output at Android Virtual Device - > go to Terminal at Visual studio and
type -> C:\projects\reactnative\BMICALC>npm run android

12. BMI is a measure of body fat based on height and weight of adult men and women. The
Formula for calculating the BMI in metric units is as follows.
BMI = weight (Kg)/ [height (m)]^2
PROGRAM :
import React, { Component } from 'react'
import { View, Text, TouchableOpacity, TextInput, StyleSheet } from 'react-native'
class Inputs extends Component {
state = {
height: '',
weight: '',
bmi: '',
BmiResult: '',
}
handleHeight = (text) => {
this.setState({ height: text })
}
handleWeight = (text) => {
this.setState({ weight: text })
}
calculate = (height, weight) => {
//calculation
var result = (parseFloat(weight)*10000)/(parseFloat(height)*parseFloat(height));
result = result.toFixed(2);
//display result
this.setState({ bmi: result })
if(result<18.5){
this.setState({BmiResult:'Underweight'})
}
else if(result>=18.5&&result<25){
this.setState({BmiResult:'Normal weight'})
}
else if(result>=25&&result<30){
this.setState({BmiResult:'Overweight'})
}
else if(result>=30){
this.setState({BmiResult:'Obese'})
}
else{
alert('Incorrect Input!');
this.setState({BmiResult:''})
}
}
render() {
return (
<View style = {styles.container}><Text style={styles.title}>BMI Calculator</Text>
<Text style = {styles.label}>Height</Text>
<TextInput style = {styles.input}
underlineColorAndroid = "transparent"
placeholder = "Height (Cm)"
autoCapitalize = "none"
onChangeText = {this.handleHeight}/><Text style = {styles.label}>Weight</Text>
<TextInput style = {styles.input}
underlineColorAndroid = "transparent"
placeholder = "Weight (Kg)"
autoCapitalize = "none"
onChangeText = {this.handleWeight}/>
<TouchableOpacity
style = {styles.submitButton}
onPress = {
() => this.calculate(this.state.height, this.state.weight)
}>
<Text style = {styles.submitButtonText}> Calculate </Text>
</TouchableOpacity><Text style = {styles.output}>{this.state.bmi}</Text>
<Text style = {styles.resultText}>{this.state.BmiResult}</Text></View>
)
}
}
export default Inputs;
const styles = StyleSheet.create({
container: {
paddingTop: 23,
},
input: {
margin: 15,
height: 40,
borderWidth: 1,
padding: 10,
},
submitButton: {
backgroundColor: '#ff6666',
padding: 10,
margin: 15,
height: 40,
},
submitButtonText:{
textAlign: "center",
color: 'white',
// fontWeight:"bold",
fontSize: 18,
},
output:{
textAlign: "center",
fontSize: 30,
},
title:{
paddingTop:30,
paddingBottom:10,
textAlign: "center",
fontSize: 30,
fontWeight:"bold",
},
resultText:{
paddingTop:20,
paddingBottom:10,
textAlign: "center",
fontSize: 30,
color: 'blue'
},
label:{
marginLeft: 15,
}})
OUTPUT:

RESULT:
Thus the program to perform BMI Calculator using React Native - Cross Platform
Application was completed and the output was verified successfully.
Ex.no: 2 SIMPLE EXPENSE MANAGER
Date:- A Cross Platform Application using IONIC

AIM:
To write a Ionic Application which perform a Simple Expense Manager using Cross
Platform App Development in Windows.
ALGORITHM :
1. Nodejs V.14 or greater and JDK 11 or higher is required.
2. Install Chocolatey for window which ensure Node LTS and JDK 11 was properly installed
by pressing Windows button -> cmd.exe (run as administrator) -> paste the following path

C:\WINDOWS\system32>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell
.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" &&
SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

3. Check Chocolatey was installed properly verify at: ‘C:\ ProgramData\ chocolatey\ bin\
choco.exe’
4. Install Nodejs and JDK with code: choco install –y nodejs-lts openjdk11
5. Install AndroidStudio with Android SDK tools & platform with Virtual Devices.
5.1 Install stable SDK Platform either Android 12.0 or Android 13.0 version
5.2 Install Intel x86 Atom_64 System Image in SDK package.
5.3 Install SDK Build tools with either 31.00 or 33.00 version
6. Set the Environmental Variable:
ANDROID_HOME: C:\Users\ System_Name\ AppData\Local\Android\Sdk>
7. The Ionic CLI can be installed globally with npm code :
npm install -g @ionic/cli
8. Start an App : The three most common starters are the blank starter, tabs starter, and
sidemenu starter. Get started with the
ionic start
9. Run the App : The majority of Ionic app development can be spent right in the
browser using the ionic serve command
$ cd myApp
$ ionic serve
10. If you run this application on Android version 10 (API 29+) or above you need to
enter the follow line in the AndroidManifest file under the application tag;
android:requestLegacyExternalStorage="true"
11. Create code on Angular-based codebase that runs on the web, iOS, and Android
using Ionic Framework UI components.
12. Adding Capacitor : You can also add Capacitor to your application by choosing
"Integrate Capacitor". you can now run your app on web, Android, and iOS with the "Run
On Web", "Run On Android", and "Run On iOS" options.

PROGRAM :
Home.page.html code :
<ion-header [translucent]="true">
<ion-toolbar color="dark" align="center">
<ion-title>
Expenses Application
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Expenses Application</ion-title>
</ion-toolbar>
</ion-header>

<div id="container">
<ion-grid class="ion-align-items-center">
<ion-row>
<ion-col>
<ion-button href="/add-expense/" color="success">Add Expense</ion-button>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-button href="/view-expenses/" color="tertiary">View Expenses</ion-button>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-button color="danger">Exit Application</ion-button>
</ion-col>
</ion-row>
</ion-grid>
</div>
</ion-content>

add.expense.page.html Code:
<ion-header>
<ion-toolbar color="success">
<ion-title>Add Expense</ion-title>
<ion-buttons slot="start">
<ion-back-button defaultHref="home"></ion-back-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="fileDelete()">
<ion-icon name="trash" slot="icon-only"> </ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-card>
<ion-card-header color="success"><Strong>1. Name and Date of Expense</Strong></ion-
card-header>
<ion-item>
<ion-label position="floating">Expense Name</ion-label>
<ion-input type="text" [(ngModel)] ="expense.Name" id="input-name"></ion-input>
</ion-item>
<ion-item>
<ion-label>Date on Receipt</ion-label>
<ion-datetime display-format="DD MMM YYYY" placeholder="Select Date" [(ngModel)]
="expense.Date" id="expense_date"></ion-datetime>
</ion-item>
</ion-card>
<ion-card>
<ion-card-header color="success"><Strong>2. Add Receipt Line</Strong></ion-card-
header>
<ion-item>
<ion-label position="floating">Line Description</ion-label>
<ion-input type="text" [(ngModel)] ="expense.Reason" id="input-reason"></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">Amount</ion-label>
<ion-input type="number" [(ngModel)] ="expense.Amount" id="input-amount"></ion-
input>
</ion-item>
<div class="ion-margin-vertical ion-text-center">
<ion-button (click)="clearList()" fill="outline" color="danger" id="btn-cancel">
<ion-icon name="close" slot="start"></ion-icon>Clear Lines</ion-button>
<ion-button id="btn-confirm" (click)="addLine()">
<ion-icon name="add-outline" slot="start"></ion-icon>Add Line</ion-button>
</div>
</ion-card>
<ion-card color="dark">
<ion-card-header><Strong>Added Receipt Lines</Strong></ion-card-header>
<ion-grid color="dark">
<ion-row color="dark">
<ion-col color="dark">
<ion-list color="dark" class="ion-no-padding">
<ion-item lines="none" color="dark" *ngFor="let exp of expList">
<ion-label class="ion-text-wrap">{{ exp }}</ion-label>
</ion-item>
</ion-list>
</ion-col>
<ion-col>
<ion-list class="ion-no-padding">
<ion-item lines="none" color="dark" *ngFor="let exp of expListAmount">
<ion-label class="ion-text-wrap ion-text-right">{{ exp }}</ion-label>
</ion-item>
</ion-list>
</ion-col>
</ion-row>
</ion-grid>
<h3 align="center">Receipt Amount: £{{ totalExpense }}</h3>
</ion-card>
<ion-card>
<ion-card-header color="success"><Strong>3. Receipt Picture</Strong></ion-card-header>
<app-image-picker (imagePick)="onImagePicked($event)"></app-image-picker>
</ion-card>
<ion-card>
<ion-card-header color="success"><Strong>Help Me, Please Help Me!</Strong></ion-card-
header>
<ion-grid>
<ion-row>
<ion-col size-md="6" offset-md="3">
<div>
<p align="center">Enter each receipt under a new expence. Enter each line into the app as it
is displayed
on the receipt and take a picture of the receipt as proof of exepense. The app will
autosave, if you want to delete the expense click on the bin icon in the top right of your
screen.
You can also delete expense claims under the View Expenses Screen.
Press the back button to go back to the main menu once all lines have been entered</p>
<p></p>
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-card>
</ion-content>

view-expenses.page.html code :
<ion-header>
<ion-toolbar color="tertiary">
<ion-title>View Expenses</ion-title>
<ion-buttons slot="start">
<ion-back-button defaultHref="home"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<div id="container">
<ion-grid>
<ion-row>
<ion-col>
<ion-label class="ion-align-items-center"> This page does not display anything for the
example application as this was not in the specification</ion-label>
</ion-col>
</ion-row>
</ion-grid>
</div>
</ion-content>

expense-list.html Code:
<ion-item *ngFor="let exp of expList">
<p>{{ exp }}</p>
</ion-item>

AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.ionic.starter">
<application
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScr
eenSize|screenLayout|uiMode"
android:name="io.ionic.starter.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/custom_url_scheme" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Navigator.getUserMedia -->
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
</manifest>
OUTPUT:

RESULT:
Thus the program to perform a Simple Expense Manager using Ionic - Cross Platform
Application was completed and the output was verified successfully.
Ex.no: 3 Unit Convertor - Imperial System to Metric System
Date:- A Cross Platform Application using Flutter

AIM:
To write a Flutter Application which perform a Unit Convertor – Imperial System to
Metric System using Cross Platform App Development in Windows.
ALGORITHM :
1. Download the following installation bundle zip file and extract in C Drive to get the latest
stable release of the Flutter SDK from https://docs.flutter.dev/get-started/install/windows
2. Update your path : Set the Environmental Variable as named Path with the full path to
flutter\bin as its value.
3. Run flutter doctor : at Command kindly type
C:\src\flutter>flutter doctor
This command checks your environment and displays a report of the status of your Flutter
installation.
4. Install Android Studio, Set up the Android emulator for viewing the output and verify the
AVD configuration is correct, and select Finish.
5. Write a dart program to convert Imperial System to Metric System with the formula.

PROGRAM :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(myApp());
class myApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: testApp(),
);
}
}
class testApp extends StatefulWidget {
@override
_testAppState createState() => _testAppState();
}
class _testAppState extends State<testApp> {
@override
double _userInput;
String _convertedMeasure;
String errorMessage;
String _startValue;
var fromUnits = [
'Meters',
'Kilometer',
'Grams',
'Kilograms (kg)',
'Feet',
'Miles',
'Pounds (lbs)',
'ounces'
];
final Map<String,int> measuresMap ={
'Meters':0,
'Kilometer':1,
'Grams':2,
'Kilograms (kg)':3,
'Feet':4,
'Miles':5,
'Pounds (lbs)':6,
'ounces':7
};
dynamic formulas ={
'0':[1,0.001,0,0,3.280,0.0006213,0],
'1':[1000,1,0,0,3280.84,0,6213,0,0],
'2':[0,0,1,0.0001,0,0,0.00220,0.03],
'3':[0,0,1000,1,0,0,2.2046,35.274],
'4':[0.0348,0.00030,0,0,1,0.000189],
'5':[1609.34,1.60934,0,05280,1,0,0],
'6':[0,0,453.592,0.4535,0,0,1,16],
'7':[0,0,28.3495,0.02834,3.28084,0,0.1]
};
void converter (double value,String from,String to)
{
int nFrom=measuresMap[from];
int nTo=measuresMap[to];
var multiplier=formulas[nFrom.toString()][nTo];
var result=value * multiplier;
if(result==0)
{
errorMessage='Cannot Performed This Conversion';
}
else
{
errorMessage='${_userInput.toString()} $_startValue are ${result.toString()}
$_convertedMeasure';
}
setState(() {
errorMessage=errorMessage;
});
}
void initState() {
_userInput = 0;
super.initState();
}
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.deepPurpleAccent,
body: SingleChildScrollView(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 30),
child: Column(
children: [
Text('Measures',style: TextStyle(fontWeight: FontWeight.w700,fontSize: 50,color:
Colors.white),),
Text('Converter!',style: TextStyle(fontWeight: FontWeight.w700,fontSize: 50,color:
Colors.white),),
SizedBox(height: 20,),
Padding(
padding: const EdgeInsets.symmetric(vertical: 20,horizontal: 40),
child: TextField(
style: TextStyle(fontSize: 20,color: Colors.white),
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey[400],
hintText: 'Enter Your Value',
hintStyle: TextStyle(color: Colors.white),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(50),
),
),
onChanged: (text){
var input=double.tryParse(text);
if(input!=null)
{
setState(() {
_userInput=input;
});
}
},
),
),
SizedBox(height: 10,),
Text('From',style: TextStyle(fontSize: 20,color: Colors.white),),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40,vertical: 10),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 5),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadiusDirectional.circular(50),
),
child: DropdownButtonHideUnderline(
child: DropdownButton(
hint: Text('Choose Your Unit',style: TextStyle(color: Colors.amber),),
dropdownColor: Colors.black,
isExpanded: true,style: TextStyle(
fontSize: 20,color: Colors.amber
), items: fromUnits.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),);
} ).toList(),
onChanged: (String value){
setState(() {
_startValue=value;
});
},
value: _startValue,
),
),
),
),
SizedBox(height: 10,),
Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: FlatButton(
onPressed: (){
if(_startValue.isEmpty || _convertedMeasure.isEmpty || _userInput==0)
return;
else {
converter(_userInput, _startValue, _convertedMeasure);
}
},
child: Container(
alignment: AlignmentDirectional.center,
width: 200,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(20),
),
child: Text('Convert',style: TextStyle(fontSize: 30,color: Colors.amber),),
),
),
),
SizedBox(height: 10,),
Text((errorMessage==null)?'':errorMessage ,
style: TextStyle(fontSize: 30,fontWeight: FontWeight.w700),)
],
),
),
),
),);
}
}
OUTPUT:

RESULT:
Thus the program to perform a Unit Convertor – Imperial System to Metric System
using Flutter- Cross Platform Application was completed and the output was verified
successfully.
Ex.no: 4 To-Do List Application
Date:- A Cross Platform Application using Xamarin

AIM:
To write a Xamarin Application which perform a To-Do List Applicationusing CrossPlatform
App Development in Windows.
ALGORITHM :
Step 1 - Create Android Project:Create your Android solution in Visual Studio or Xamarin
Studio. Select Android and from the list, choose Android Blank App. Give it a name, like
ToDoList.
Step 2 - Add Android Support v7 AppCompat Library:First of all, in References, add a
reference of Android.Support.v7. AppCompat using NuGet Package Manager, as shown
below.
Step 3 - Main Layout:Open Solution Explorer-> Project Name-> Resources-> Layout->
Main.axml. Open this main layout file and add the following code.
(File Name: Main.axml , Folder Name: Layout)
XML Code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/lstTask"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Step 4 - Add New Layout:Next, add a new layout by going to Solution Explorer-> Project
Name-> Resources-> Layout. Right-click to add a new item, select Layout, and give it a
name, such as row.axml. Open this layout file and add the following code.
(Folder Name: Layout , File Name: row.axml)
XML Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/task_title"
android:text="Example"
android:textSize="20sp"
android:textColor="@android:color/black"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btnDelete"
android:text="DELETE"
android:textSize="20sp"
android:textColor="@android:color/black"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
Step 5 - Add Menu:Next, add a new folder by going to Solution Explorer-> Project Name->
Resources-> Right-click to add a new folder. Give it a name, like Menu, and right-click on
menu folder to add a new item. Select XML, and give it a name as menu_item.xml. Open this
XML file and add the following code.
(Folder Name: menu , File Name: menu_item.xml)
XML Code
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_add"
android:icon="@android:drawable/ic_menu_add"
android:title="Add New Task"
android:showAsAction="always"/>
</menu>
Step 6 - Writing DbHelper Class:Before you go further, you need to write your DbHelper
Class. For this, go to Solution Explorer-> Project Name and right-click. Select Add -> New
Item-> Class. Give it a name like DbHelper.cs and write the following code with appropriate
namespaces.
(File Name: DbHelper.cs)

C# Code
using Android.Content;
using Android.Database;
using Android.Database.Sqlite;
using System;
using System.Collections.Generic;
namespace ToDoList.Helper
{
public class DbHelper : SQLiteOpenHelper
{
private static String DB_NAME = "Ahsan";
private static int DB_VERSION = 1;
private static String DB_TABLE = "Task";
private static String DB_COLUMN = "TaskName";
public DbHelper(Context context) : base(context, DB_NAME, null, DB_VERSION)
{
}
public override void OnCreate(SQLiteDatabase db)
{
string query = $"CREATE TABLE {DbHelper.DB_TABLE} (ID INTEGER
PRIMARY KEY AUTOINCREMENT, {DbHelper.DB_COLUMN} TEXT NOT NULL);";
db.ExecSQL(query);
}
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
string query = $"DELETE TABLE IF EXISTS {DB_TABLE}";
db.ExecSQL(query);
OnCreate(db);
}
public void InsertNewTask(String task)
{
SQLiteDatabase db = this.WritableDatabase;
ContentValues values = new ContentValues();
values.Put(DB_COLUMN, task);
db.InsertWithOnConflict(DB_TABLE, null, values,
Android.Database.Sqlite.Conflict.Replace);
db.Close();
}
public void deleteTask(String task)
{
SQLiteDatabase db = this.WritableDatabase;
db.Delete(DB_TABLE, DB_COLUMN + " = ?", new String[] { task });
db.Close();
}
public List<string> getTaskList()
{
List<string> taskList = new List<string>();
SQLiteDatabase db = this.ReadableDatabase;
ICursor cursor = db.Query(DB_TABLE, new string[] { DB_COLUMN }, null, null,
null, null, null);
while (cursor.MoveToNext())
{
int index = cursor.GetColumnIndex(DB_COLUMN);
taskList.Add(cursor.GetString(index));
}
return taskList;
}
}
}
Step 7 - Writing CustomAdapter Class :Similarly, add a new class - CustomAdapter.cs and
add the following code with appropriate namespaces.
(File Name: CustomAdapter.cs)

C# Code
using Android.Content;
using Android.Views;
using Android.Widget;
using System.Collections.Generic;
namespace ToDoList.Helper
{
public class CustomAdapter : BaseAdapter
{
private MainActivity mainActivity;
private List<string> taskList;
private DbHelper dbHelper;
public CustomAdapter(MainActivity mainActivity, List<string> taskList, DbHelper
dbHelper)
{
this.mainActivity = mainActivity;
this.taskList = taskList;
this.dbHelper = dbHelper;
}
public override int Count { get { return taskList.Count; } }
public override Java.Lang.Object GetItem(int position)
{
return position;
}
public override long GetItemId(int position)
{
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater =
(LayoutInflater)mainActivity.GetSystemService(Context.LayoutInflaterService);
View view = inflater.Inflate(Resource.Layout.row, null);
TextView txtTask = view.FindViewById<TextView>(Resource.Id.task_title);
Button btnDelete = view.FindViewById<Button>(Resource.Id.btnDelete);
txtTask.Text = taskList[position];
btnDelete.Click += delegate
{
string task = taskList[position];
dbHelper.deleteTask(task);
mainActivity.LoadTaskList(); // Reload Data
};
return view;
}
}
}
Step 8 - Main Activity Class : Now, go to Solution Explorer-> Project Name-> MainActivity
and add the following code with appropriate namespaces.
(FileName: MainActivity)
C# Code
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Support.V7.App;
using Android.Views;
using Android.Content;
using System;
using ToDoList.Helper;
using System.Collections.Generic;
namespace ToDoList
{
[Activity(Label = "ToDoList", MainLauncher = true , Theme
="@style/Theme.AppCompat.Light")]
public class MainActivity : AppCompatActivity
{
EditText edtTask;
DbHelper dbHelper;
CustomAdapter adapter;
ListView lstTask;
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.menu_item, menu);
return base.OnCreateOptionsMenu(menu);
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.action_add:
edtTask = new EditText(this);
Android.Support.V7.App.AlertDialog alertDialog = new
Android.Support.V7.App.AlertDialog.Builder(this)
.SetTitle("Add New Task")
.SetMessage("What do you want to do next?")
.SetView(edtTask)
.SetPositiveButton("Add", OkAction)
.SetNegativeButton("Cancel", CancelAction)
.Create();
alertDialog.Show();
return true;
}
return base.OnOptionsItemSelected(item);
}
private void CancelAction(object sender, DialogClickEventArgs e)
{
}
private void OkAction(object sender, DialogClickEventArgs e)
{
string task = edtTask.Text;
dbHelper.InsertNewTask(task);
LoadTaskList();
}
public void LoadTaskList()
{
List<string> taskList = dbHelper.getTaskList();
adapter = new CustomAdapter(this, taskList, dbHelper);
lstTask.Adapter = adapter;
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
dbHelper = new DbHelper(this);
lstTask = FindViewById<ListView>(Resource.Id.lstTask);
//Load Data
LoadTaskList();
}
}
}
Output:

Result :
Thus the program to perform a To-Do List Application using Xamarin - Cross
Platform App Development was completed and the output was verified successfully.
Ex.no: 5 User Login Android Application using Layout Manager
Date:- A Hybrid Platform Application using Apache Cordova

AIM:
To write anApache Cordova Application which perform a User Login Android
Applicationusing HybridApp Development in Windows.
ALGORITHM :
1. Setup Cordova Project:
- Install Cordova if you haven't already by running `npm install -g cordova`.
- Create a new Cordova project: `cordova create UserLoginApp
com.example.userlogin UserLoginApp`.

2. Add Android Platform:


- Navigate to your project directory: `cd UserLoginApp`.
- Add the Android platform: `cordova platform add android`.

3. Implement User Authentication:


- You can implement user authentication using a framework like Firebase
Authentication or a custom server with APIs.
- Firebase Authentication is a popular choice and has Cordova plugins
available.

4. Install Cordova Plugins:


- Install relevant Cordova plugins for user authentication. For Firebase
Authentication, you can use the "cordova-plugin-firebase-authentication."
5. Create the User Interface:
- Design your login and registration screens. You can use HTML, CSS, and
JavaScript for this within the Cordova project.
6. Implement User Authentication Logic:
- In your JavaScript code, implement the logic for user registration and login using
the Cordova plugin and the chosen authentication system.
7. Test on Android Emulator/Device:
- Connect your Android device or use an emulator.
- Run your Cordova app on Android: `cordova run android`.
8. Build and Distribute:

- Build your Cordova app for Android using `cordova build android`.
- Distribute your app through the Google Play Store or other distribution channels.
PROGRAM :
HTML CODE :

<!DOCTYPE html>
<html>
<head>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<div class="header">
<img src="img/header_image.png" alt="Header Image">
<h1>Login</h1>
</div>
<div class="login-form">
<label for="username">Username</label>
<input type="text" id="username" placeholder="Enter your username" required>

<label for="password">Password</label>
<input type="password" id="password" placeholder="Enter your password" required>
<button id="reset-button">Reset</button>
<button id="submit-button">Submit</button>
</div>
<script src="js/index.js"></script>
</body>
</html>

CSS Code :

body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}

.header {
text-align: center;
padding: 20px;
background-color: #333;
color: #fff;
}

.header img {
width: 150px;
height: 150px;
}

.login-form {
background-color: #fff;
border: 1px solid #ccc;
padding: 20px;
margin: 20px;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

label {
display: block;
margin-top: 10px;
}

input {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 3px;
}

button {
padding: 10px 20px;
margin-top: 10px;
background-color: #333;
color: #fff;
border: none;
border-radius: 3px;
cursor: pointer;
}

button:hover {
background-color: #555;
}

JS Code :

javascript
document.addEventListener('deviceready', function() {
// DOM elements
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
const resetButton = document.getElementById('reset-button');
const submitButton = document.getElementById('submit-button');

// Event listener for the Reset button


resetButton.addEventListener('click', function(event) {
event.preventDefault();
usernameInput.value = ''; // Clear username input
passwordInput.value = ''; // Clear password input
});
// Event listener for the Submit button
submitButton.addEventListener('click', function(event) {
event.preventDefault();

// Get the values entered by the user


const username = usernameInput.value;
const password = passwordInput.value;

// Basic form validation (you can enhance this)


if (username.trim() === '' || password.trim() === '') {
alert('Please enter both username and password.');
} else if (username === 'admin' && password === '23') {
alert('Login successful!)';
// You can navigate to another page or perform additional actions here.
} else {
alert('Login failed. Please check your credentials.’);
}
});
});

Output:
Result :
Thus the program to perform a User Login Android Application using Apache
Cordova - Hybrid App Development was completed and the output was verified successfully.
Ex.no: 6 User Current Location Identifier using Android
Date:- A Hybrid Platform Application using Apache Cordova

AIM:
To write an Apache Cordova Application in android which find and display the user current
location using Hybrid App Development in Windows.
ALGORITHM :
1. To create a new ionic project you need to execute following commands on your terminal.
ionic start AppName blank
2. Once you have created a new project, we need to change our working directory for adding
platform and plugins to do that
cd AppName
3. If you want to run your project on the browser, you can execute - ionic serve
4. To add a new platform, we need to execute following commands (If you want to build/run
your application for a device, you must add platform)
ionic cordova platform add
ionic cordova platform add android
ionic cordova platform add ios
5. If you want to add plugin, you can follow this - ionic cordova plugin add <plugin-name>
ionic cordova plugin add cordova-plugin-geolocation
npm install @ionic-native/geolocation
6. If you want to generate executable or want to build, you need to follow this
ionic cordova build android
ionic cordova build ios
7. If you want to run your current application on connected device/emulator, you can execute
the following command
ionic cordova run android
ionic cordova run ios
8. This API requires the following permissions be added to your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
PROGRAM :
app.module.ts :

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


import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';


import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';


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

import { HttpClientModule } from '@angular/common/http';

import { Geolocation } from '@ionic-native/geolocation/ngx';

@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule],
providers: [
StatusBar,
SplashScreen,
Geolocation,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule { }

home.page.html:

<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
NSCET
</ion-title>
</ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
<div class="container">
<p>Lat: {{lat}}, Lng: {{lng}}</p>
<ion-button (click)="whereIam()">Where I am?</ion-button>
</div>
</ion-content>
home.page.scss :

.container{
display: flex;
height: 100%;
justify-content: center;
align-items: center;
flex-direction: column;
}
home.page.ts :
import { Component } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation/ngx';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
lat;
lng;
constructor(
private geo: Geolocation
){
}
whereIam() {
this.geo.getCurrentPosition({
timeout: 10000,
enableHighAccuracy: true
}).then((res) => {
this.lat = res.coords.latitude;
this.lng = res.coords.longitude;
}).catch((e) => {
console.log(e);
});
}

}
Output:

Result :
Thus the program to find and display user current location using Apache Cordova in
Android - Hybrid App Development was completed and the output was verified successfully.
Ex.no: 7 Simple Library Application
Date:- An Android Application with Databases

AIM:
To write a simple library application in android to displaying books available, books lend,
book reservation and student information is available in a database which has been stored in a
database server in Windows.
ALGORITHM:
1. Create a New Android Project:
• Click New in the toolbar.
• In the window that appears, open the Android folder, select Android Application
Project, and click next.
• Provide the application name and the project name and then finally give the
desired package name.
• Choose a launcher icon for your application and then select Blank Activity and
then click Next
• Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
• Click Android Virtual Device Manager from the toolbar.
• In the Android Virtual Device Manager panel, click New.
• Fill in the details for the AVD. Give it a name, a platform target, an SD card size,
and a skin (HVGA is default).
• Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout.
4. Run the application.
5. Perform the database operation to displaying books available, books lend, book reservation
and student information is available in a database which has been stored in a database server.
(Insert/delete/view/update)
6. Close the Android project.

PROGRAM :
Admin Java:
package

com.iiitnr.libraryapp;

public class Admin {

private int type;


private String name, email;
public String getFcmToken() {
return fcmToken;
}

public void setFcmToken(String fcmToken)


{ this.fcmToken = fcmToken;
}

private String

fcmToken; public

Admin() {
}

public Admin(int type, String name, String email)


{ this.type = type;
this.name = name;
this.email = email;
}

public int getType() {


return type;
}

public void setType(int type) {


this.type = type;
}

public String getName() {


return name;}
public void setName(String name) {
this.name = name;}
public String getEmail() {
return email;}

public void setEmail(String email) {


this.email = email;}}
Book Java:
package
com.iiitnr.libraryapp;
import java.util.ArrayList;
import java.util.List;

public class Book {

private String title,

type;
private int total = 0, available = 0, id;
private List<Integer> unit = new ArrayList<Integer>();

public Book() {
}

public Book(String title, String type, int total, int id) {


this.title = title;
this.type = type;
this.total = total;
this.id = id;
this.available=total;
}

public String getTitle()


{ return title;
}

public void setTitle(String title)


{ this.title = title;
}

public String getType()


{ return type;
}

public void setType(String


type) { this.type = type;
}

public int getTotal() {


return total;
}

public void setTotal(int total) {


this.total = total;
}

public int getAvailable() {


return available;
}

public void setAvailable(int available) {


this.available = available;
}

public int getId()


{ return id;
}

public void setId(int id)


{ this.id = id;
}

public List<Integer> getUnit()


{ return unit;
}

public void setUnit(List<Integer> unit) {


this.unit = unit;
}
}

User Home Java:


package com.iiitnr.libraryapp;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import
android.widget.TextView;
import android.widget.Toast;

import
com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import
com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.FirebaseFirestore;

public class UserHome extends AppCompatActivity implements View.OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_home);
FirebaseApp.initializeApp(this);
firebaseAuth=FirebaseAuth.getInstance();
title1=(TextView)findViewById(R.id.title1);
searchBook1=(Button)findViewById(R.id.searchBook1);
seeBook=(Button)findViewById(R.id.seeBook);
logOut1=(Button)findViewById(R.id.logOut1);
buttonReissue=(Button)findViewById(R.id.buttonReissue);

db=FirebaseFirestore.getInstance();
searchBook1.setOnClickListener(this);
seeBook.setOnClickListener(this);
logOut1.setOnClickListener(this);
buttonReissue.setOnClickListener(this);}
private TextView title1;
private Button searchBook1,seeBook,logOut1,buttonReissue;
private FirebaseAuth firebaseAuth;
private FirebaseFirestore db;
@Override
public void onClick(View v) {
if(v==logOut1)
{
db.document("User/"+firebaseAuth.getCurrentUser().getEmail()).update("fcmToken",
nu ll).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
{

firebaseAuth.signOut();
startActivity(new
Intent(getApplicationContext(),SignInActivity.class)); finish();
}
else
{
Toast.makeText(UserHome.this, "Try Again !", Toast.LENGTH_SHORT)
.show();
} }
});
}

if(v==searchBook1)
{
startActivity(new Intent(getApplicationContext(),SearchBookSet.class));
}

if(v==seeBook)
{
startActivity(new Intent(getApplicationContext(),UserSeeMyBooks.class));
}

if(v==buttonReissue)
{
startActivity(new Intent(getApplicationContext(),UserReissueBook.class));}}}

Issue Book Java:


package com.iiitnr.libraryapp;

import android.app.AlertDialog;
import
android.app.ProgressDialog;
import android.content.DialogInterface;
import android.nfc.Tag;
import android.support.annotation.NonNull;
import
android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import
android.widget.Button;
import
android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import
com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.Timestamp;
import
com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;

import
java.text.SimpleDateFormat;
import java.util.ArrayList;
import
java.util.Calendar;
import java.util.Date;
import java.util.List;

public class AdminIssueBook extends AppCompatActivity {


private TextInputLayout editCardNo1,
editBid3; private FirebaseFirestore db;
private ProgressDialog p;
private boolean res1, res2;
private User U = new User();
private Book B1 = new
Book();
@Override
public void onBackPressed()
{ finish();
super.onBackPressed();}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_issue_book);
FirebaseApp.initializeApp(this);
Button issueButton = (Button) findViewById(R.id.issueButton);
editBid3 = (TextInputLayout) findViewById(R.id.editBid3);
editCardNo1 = (TextInputLayout)
findViewById(R.id.editCardNo1);
db=FirebaseFirestore.getInstance();
p = new ProgressDialog(this);
issueButton.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
issueBook();
}});}

private boolean verifyCard() {


String t =
editCardNo1.getEditText().getText().toString().trim(); if
(t.isEmpty()) {
editCardNo1.setErrorEnabled(true);
editCardNo1.setError("Card No. Required");
return true;
} else {
editCardNo1.setErrorEnabled(false);
return false;
}
}

private boolean verifyBid() {


String t =
editBid3.getEditText().getText().toString().trim(); if
(t.isEmpty()) {
editBid3.setErrorEnabled(true);
editBid3.setError("Book Id Required");
return true;
} else {
editBid3.setErrorEnabled(false);
return false;
}
}

private boolean getUser() {


db.collection("User").whereEqualTo("card
",
Integer.parseInt(editCardNo1.getEditText().getText().toString().trim())).get().addOnC
om pleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {

if (task.isSuccessful()) {
if (task.getResult().size() == 1) {
res1 = true;
for (QueryDocumentSnapshot doc :
task.getResult()) U = doc.toObject(User.class);
} else {

res1 = false;
p.cancel();
Toast.makeText(AdminIssueBook.this, "No Such User !",
Toast.LENGTH_SHORT).show();
}
} else {
res1 = false;
p.cancel();
Toast.makeText(AdminIssueBook.this, "Try Again !",
Toast.LENGTH_SHORT).show();}
});
return res1;}

private boolean getBook() {

db.document("Book/" +
Integer.parseInt(editBid3.getEditText().getText().toString().trim()) /
100).get().addOnCompleteListener(new
OnCompleteListener<DocumentSnapshot>() { @Override
public void onComplete(@NonNull Task<DocumentSnapshot>
task) { if (task.isSuccessful()) {
if (task.getResult().exists()) {
res2 = true;
B1 = task.getResult().toObject(Book.class);
} else {
res2 = false;
p.cancel();
Toast.makeText(AdminIssueBook.this, "No Such Book !",
Toast.LENGTH_SHORT).show();
}
} else {
res2 = false;
p.cancel();
Toast.makeText(AdminIssueBook.this, "Try Again !",
Toast.LENGTH_SHORT).show();
}
}
});
return res2;
}

private void issueBook() {

Log.d("abc","invoked");
if (verifyBid() | verifyCard())
{ return;
}
p.setMessage("Please Wait
!"); p.show();
if (getBook()&getUser())
{

if (U.getBook().size() >= 5) {
p.cancel();
Toast.makeText(AdminIssueBook.this, "User Already Has 5 books issued
!", Toast.LENGTH_SHORT).show();
return;
}
if (B1.getAvailable() == 0)
{ p.cancel();
Toast.makeText(AdminIssueBook.this, "No Units of this Book Available
!", Toast.LENGTH_SHORT).show();
return;
}
if
(B1.getUnit().contains(Integer.parseInt(editBid3.getEditText().getText().toString().tri
m()
) % 100)) {
p.cancel();
Toast.makeText(AdminIssueBook.this, "This Unit is Already Issued
!", Toast.LENGTH_SHORT).show();
return;
}
List<Integer> l = new
ArrayList<Integer>(); l = U.getBook();
l.add(Integer.parseInt(editBid3.getEditText().getText().toString().trim()));
U.setBook(l);
l = U.getFine();
l.add(0);
U.setFine(l);
l = U.getRe();
l.add(1);
U.setRe(l);
List<Timestamp> l1 = new
ArrayList<>(); l1 = U.getDate();
Calendar c = new Calendar() {
@Override
protected void computeTime() {
}

@Override
protected void computeFields() {
}
@Override
public void add(int field, int amount) {
}

@Override
public void roll(int field, boolean up) {
}

@Override
public int getMinimum(int field) {
return 0;
}

@Override
public int getMaximum(int field) {
return 0;
}

@Override
public int getGreatestMinimum(int field) {
return 0;
}

@Override
public int getLeastMaximum(int
field) { return 0;
}
};
c=Calendar.getInstance();
Date d = c.getTime();
Timestamp t = new Timestamp(d);
l1.add(t);
U.setDate(l1);
db.document("User/"+U.getEmail()).set(U).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
B1.setAvailable(B1.getAvailable()-
1); List<Integer> l1=new
ArrayList<>(); l1=B1.getUnit();
l1.add(Integer.parseInt(editBid3.getEditText().getText().toString().trim()) %
100); B1.setUnit(l1);
db.document("Book/"+B1.getId()).set(B1).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void>
task) { if (task.isSuccessful()) {
p.cancel();
Toast.makeText(AdminIssueBook.this, "Book Issued Successfully !",
Toast.LENGTH_SHORT).show();
} else {
p.cancel();
Toast.makeText(AdminIssueBook.this, "Try Again !",
Toast.LENGTH_SHORT).show();
}
}
});
} else {
p.cancel();
Toast.makeText(AdminIssueBook.this, "Try Again !",
Toast.LENGTH_SHORT).show();
}
}
});
Output:
Result :
Thus the program to write a simple library application in android to displaying books
available, books lend, book reservation and store it in database server was completed and the
output was verified successfully.

You might also like