Ccs332 App Development Lab Manual
Ccs332 App Development Lab Manual
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
Department: CSE
Name : ………………………………………….
Register No : ………………………………………….
Branch : ………………………………………….
1
LIST OF EXPERIMENTS
1. Using react native, build a cross platform application for a BMI calculator
2.Build a cross platform application for a simple expense manager which allows entering
expenses and income on each day and displays category wise weekly income and expense
3.Develop a cross platform application to convert units from imperial system to metric
system
4.Design and develop a cross platform application for day to day task (to-do) management
5.Design an android application using Cordova for a user login screen with username,
password, reset budova and a submit button. Also, include header image and a label
6.Design and develop an android application using Apache Cordova to find and display the
current location of the user
7.Design and implement a simple library management system using a switch statement in
Java, where have operated the following operations Add a new book, Check Out a book,
display specific book status, search specific book, and display book details using different
classes
2
NAME OF THE PAGE DATE OF MARK
S.No. DATE SIGNATURE
EXPERIMENT NO SUBMISSION (10)
3
NAME OF THE PAGE DATE OF MARK
S.No. DATE SIGNATURE
EXPERIMENT NO SUBMISSION (10)
EXERCISE:1 Using react native, build a cross platform application for a
BMI calculator.
},
submitButtonText: {
textAlign: “center”,
color :’white’,
//font weight:” 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,
}})
Exercise : 2 Build a cross platform application for a simple expense manager
which allows entering expenses and income on each day and displays category
wise weekly income and expense.
Step1:
Create APP: Android Studio, and create a new Flutter Give the project name
"expense today”. And click. Next and follow the same to use the default
settings.
Step 2: Now delete all the code from the main.dart file.
Step3: Create the Main App Widget
main.dart
import 'package:flutter/material.dart';
final String appTitle = "Expense App";
void main() {
runApp(ExpenseApp());
}
class ExpenseApp extends Stateless Widget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: appTitle,
theme: ThemeData(
primarySwatch: Colors.green,
visualDensity: VisualDensity.adaptivePlatformDensity, ),
home: Text(appTitle),
debugShowCheckedModeBanner: false);
}}
Step 4: Run the app:
Step 5: Create a HomeScreen Stateful widget
main.dart file at the bottom after Expense App class, write the Following code.
class HomeScreen extends StatefulWidget {
constHomeScreen( ({Key key}): super(key: key);
@override
_HomeScreenStatecreateState() =>_HomeScreenState();
class_HomeScreenState extends State<HomeScreen> {
String title appTitle;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
children: [
Text("ABC"),
Text("DEF"),
],
),
),
appBar: AppBar(
title: Text(title),
),
floating ActionButton: Pressed: () {}, Floating ActionButton.extended(
onPressed : ( ) { },
label: Text('Add'),
icon: Icon(Icons.add),
backgroundColor: Colors.pink,
),
);
}}
Step 6: Update ExpenseApp Widget
class ExpenseApp extends Stateless Widget {
//
This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
…
home: HomeScreen(),
…
}
}
Step 7: Fix Test Code red line is showing under the widget_test.dart. To
remove it just change MyApp() to Expense App()
Step 8: Create a Row Widget
Step:9 Creating the Widget UI. write the following code in the
category_widget.dart file
import package flutter/material.dart';
class CategoryWidget extends StatefulWidget {
Category Widget({Key key, this rowNumber, this.callback)) super(key: key);
int rowNumber;
Function callback;
@override
_Category WidgetStatecreateState() => _CategoryWidgetState();
}
class_CategoryWidgetState extends State<CategoryWidget> {
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: constEdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.space Between, children: [
Padding(
padding: constEdgeInsets.only(right: 20),
child: Text(
"$(widget.rowNumber + 1}",
style: TextStyle(
fontSize: 20,
font Weight: Font Weight.bold,
),
),
),
Expanded(
child: TextField(
onChanged: (text) {
print(text);
},
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Category',
),
),
),
Icon(Icons.attach_money),
Expanded(
child: TextField(
onChanged: (text) {
print(text);
},
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Cost',
),
),
],
),
),
),
}
}
Step 10: Update the ListView within the class. _HomeScreenstate
class_HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
children: [
Category Widget(
rowNumber: 0,
callback: () {},
),
Category Widget(
rowNumber: 1,
callback: () {},
),
],
),
),
…
);
}
}
Step 14: onPressed function of the floating ActionButton widget and add a
reference of addRow function.
…
floatingActionButton: Floating ActionButton.extended(
onPressed: addRow,
label: Text('Add'),
icon: Icon(Icons.add),
backgroundColor: Colors.pink,
),
…
Step 15: save the file to hot reload the app. You see, the app screen is blank,
and if
you click + Add continuously a new Category Widget will be added within the
ListView.
Step 16: Update main.dart file
Now update the main.dart file by importing the new widget here.
import package:expense_today/category_widget.dart';
Step 17: update the ListView within the _HomeScreenstate class.
class_HomeScreenState extends State<HomeScreen> {
…
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
children: [
Category Widget(
rowNumber: 0,
callback: () {},
),
Category Widget(
rowNumber: 1,
callback: () {},
),
],
),
),
…
);
}}
Within the ListView you remove the old Text widgets and adds 2
CategoryWidget. You also pass rowNumber:0 for the first one and rowNumber: 1
for the second one. Currently the callback function is empty.
Step 11: Create the "+ Add" Functionality
A user will click the pink +Add button new row will be added. To do that,
let's add int
totalRow = 0; within the HomeScreenState
class_HomeScreenState extends State<HomeScreen> {
String title appTitle;
int totalRow = 0;
…
addRow function within the _HomeScreenState
class_HomeScreenState extends State< HomeScreen> {
…
void_addRow() {
setState(() {
totalRow += 1;
});
}
…
List View within the_HomeScreenWidget again: {
Ex3.2 Convert km to mi
Import React, { useState } from “react”;
export default function App( ) {
const [weightInLb, setWeightInLb] = useState(0);
const [weightInKg, setWeightInKg] = useState(0);
const calculate = (e) => {
e.preventDefault( );
constform Valid =+ weightInLb > =0;
if(!formValid){
return;
setWeightInKg(+weightInLb * 0.62137);
};
return(
<div className =”App”>
<form onSubmit ={ calculate }>
<div>
<label>Enter Km </label>
<input
Value={weightImLb}
Onchange ={ ( e) =>setWeightInLb(e.target.value)}
/>
</div>
<button type =”submit”>convert </button>
</form>
<p>{weightInKg} mi </p>
</div>
Exercise:4 Design and develop a cross platform application for day to day
task (to-do) management.
Step2: Constants-src/components/EmojiFeedback/data.js
// External
import styled from "styled-components";
// Components
import Emoji from "./Emoji";
import { Flex } from "../../styles/globalStyles";
// Reactions array
import { reactions } from "./data";
const Card styled.div'
width: 800px;
height: 500px;
background-color: #fff;
border-radius: 33px;
padding: 44px 48px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
//External
constanimationOptions = {
loop: true,
autoplay: false,
animationData: select AnimationData(reaction),
rendererSettings: {
preserveAspectRatio: "xMidYMid slice",
},
};
<Lottie
Options={animationOptions}
height ={100}
Width =”80%”
isStopped={! is Selected}
isClickToPauseDisabled
/>
{isSelected&&<EmojiLabel>{reaction}</EmojiLabel>}
</EmojiWrapper>
);
};
Exercise No 5: Design an android application using Cordova for a user login
screen with username, password, reset budova and a submit button. Also,
include header image and a label. Use layout managers.
Open Android Studio and then click on File -> New -> New project.
Le View
evigate de
Analyse
Fools VCS
Window Help
Import Project
Close Prejest
New Module
CARS
Import Module
Project Structur
CAS
Other Settings
Supert Settings
Export Setting
Save Al Synchronize
Module
Culas
CMARY Fide
Balate Caches/t
Package
Reges
C-Class
Line Separators
C/CSource Fide
CC Header File
Image Asist
Vector Asset
Singleton
300
fventing
Gradle Console
AF
New Project
Then select the Minimum SDK as shown below and click Next.
ON
110
Then delete the code which is there and type the code as given below.
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Practical Exercises
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Details Form"
android:textSize="25sp"
android:gravity="center"/>
</LinearLayout>
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:layout_marginBottom="200dp"
android:columnCount="2"
android:rowCount="3">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
App Development
android:layout_row="0"
android:layout_column="0"
android:text="Name"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="1"
android:ems="10"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="1"
android:layout_column="0"
android:text="Reg.No"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="1"
android:layout_column="1"
android:inputType="number"
android:ems="10"/>
<TextView>
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2"
android:layout_column="0"
android:text="Dept"
android:textSize="20sp"
android:gravity="center"/>
<Spinner>
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2
android:layout_column="1"
android:spinnerMode="dropdown"/>
</GridLayout>
Batton
App Development
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="150dp"
android:text="Submit"/>
RelativeLayout>
Now click on Design and your activity will look as given below.
Then delete the code which is there and type the code as given below.
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.devang.exno2.SecondActivity"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
LinearLayout>
Now click on Design andyour activity will look as given below.
So now the designing part of Second Activity is also completed.
Java Coding for the Android Application:
Java Coidng for Main Activity:
MainActivity.
Click on app -> java -> com.example.exno2 →
Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
1
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button
import android.widget.EditText;
import android.widget.Spinner;
public class MainActivity extends AppCompatActivity {
//Defining the Views
EditText el,e2;
Button bt;
Spinner s;
//Data for populating in Spinner
String [] dept_array={"CSE", "ECE", "IT", "Mech", "Civil"};
String name, reg, dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
*
Practical Exercises
setContentView(R.layout.activity_main);
//Referring the Views
el= (EditText) findViewById(R.id.editText); e2= (EditText)
findViewById(R.id.editText2);
bt= (Button) findViewById(R.id.button);
}
1
S
1
s= (Spinner) findViewById(R.id.spinner);
//Creating Adapter for Spinner for adapting the data from array to Spinner
ArrayAdapter adapter= new ArrayAdapter(MainActivity.
this,android.R.layout.simple_spinner_item,dept_array); s.setAdapter(adapter);
//Creating Listener for Button
bt.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
//Getting the Values from Views(Edittext & Spinner)
name=el.getText().toString();
reg=e2.getText().toString();
dept=s.getSelectedItem().toString();
//Intent For Navigating to Second Activity
Intent i = new Intent(MainActivity.this, SecondActivity.class);
/For Passing the Values to Second Activity
i.putExtra("name_key", name);
i.putExtra("reg_key",reg); i.putExtra("dept_key", dept);
startActivity(i);
}
});
}
}
So now the Coding part of Main Activity is completed.
Java Coding for Second Activity:
Click on app -> java -> com.example.exno2 -> SecondActivity.
Then delete the code which is there and type the code as given below.
Practical Exercises
Code for SecondActivity.java:
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class SecondActivity extends AppCompatActivity {
TextView t1, t2,t3;
String name, reg, dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
t1= (TextView) findViewById(R.id.textView1);
t2= (TextView) findViewById(R.id.textView2);
t3= (TextView) findViewById(R.id.textView3);
//Getting the Intent
Intent i = getIntent();
//Getting the Values from First Activity using the Intent eceived
name-i.getStringExtra("name_key");
reg-i.getStringExtra("reg_key");
dept-i.getStringExtra("dept_key");
//Setting the Values to Intent
11.setText(name);
12.setText(reg);
13.setText(dept);
}
}
So now the Coding part of Second Activity is also completed.
Now run the application to see the output.
Output:
VAAB 11:48
44 11:50
44 11:50
800.2
Details Form
Details Form
Name
Name
devang
devang
Reg No
Reg. No 111512104049
Dept
Dept
CSE
SUBMIT
111512104049
SUBMIT
4
D
4
6
CSE
CSE
Result:
Thus a Simple Android Application that uses Layout Managers and Event
Listeners is developed and executed successfully.
Exercise NO:6 Design and develop an android application using Apache
Cordova to find and display the current location of the user
1. Install Node.js: Make sure you have Node.js installed on your system.
2. Install Cordova: Open your terminal and run the following command to install
Cordova globally:
Copy code
npm install –g cordova
3.Create a New Cordova Project: Navigate to the directory where you want to
create your Project and run:
luaCopy code
cordova create LocationApp com.example.locationapp LocationApp
4. Navigate to your project folder:
bashCopy code
cdLocationApp
Step 2:Add Android Platform
Run the following command to add Android platform to your project:
CsharpCopy code
Cordova platform add android
Step 3:Install the Geolocation Plugin
To access the device’s geolocation ,you ‘ll need to install the Cordova
Geolocation plugin. Run the following command :
csharpCopy code
cordova plugin add cordova-plugin –geolocation
Step 4: Edit the HTML and JavaScript
Open the www folder in your project directory and
modify the index.html file to include a button to fetch the location and a
<div> to display it.
<! DOCTYPE html>
<html>
<head>
<title> Location App </title>
<script type = “ text/javascript” src=”cordova.js” > </script>
<script type = “text/javascript” src=”js/index.js”> </script>
</head>
<body>
<h1> Location App</h1>
<button id=”getLocation “ >Get Location </button>
<div id =” locationDisplay”> </div>
</body>
</html>
In the js /index.js file ,add the following code to handle the button
click and fetch the user’s location.
Step 5: Build and Run your App
Document.getElementById(“getLocation”).addEventListener(“Click”,
getLocation);
}
function getLocation( ){
navigator.geolocation.getCurrentPosition(
function(position){
var latitude =position.coords.latitude;
var longitude =position.coords.longitude;
var locationDisplay =document.getElementByid(“locationDisplay”);
locationDisplay.innerHTML =”Latitude:” +latitude + “<br>Longitude
:” + longitude;
},
function(error){
console.log(“Error getting location:” + error.message);
}
);
}
Run the following command to build and run your app on an Android emulator or
device:
arduinoCopy code
Cordova run android
Exercise 7: Design and implement a simple library management system using
a switch statement in Java, where have operated the following operations Add
a new book, Check Out a book, display specific book status, search specific
book, and display book details using different classes.
Here is the list set of options that we will be creating that are as follows:
Exit Application
Search a Book
Register Student
Library
Students
Student
books
book
A. File: book.java
Java
// Method
public book()
{
// Display message for taking input later
this.sNo input.nextInt();
input.nextLine();
this.bookName input.nextLine();
this.authorName = input.nextLine();
this.bookQty input.nextInt();
bookQtyCopy = this.bookQty;
}
B. File: books.java
Java
// CLass
Practical Exercises
// To compare books
return 0;
return 1;
// Method 2
// To add book
if (this.compareBookObjects(b, this.theBooks[i]) = 0)
return;
theBooks[count] = b;
count++;
else {
// Method 3
// Display message
System.out.println(
Practical Exercises
int sNo;
int flag = 0;
if (sNo theBooks[i].sNo) {
// Method 4
// Display message
input.nextLine();
int flag = 0;
flag++;
}
if (flag = 0)
// Method 5
+ "\t\t"+ theBooks[i].bookQty);
}
// Method 6
Display message
return,
Method 7
Practical Exercises
System.out.println(-");
// Method 8
if (sNo == theBooks[i].sNo) {
if (theBooks[i].bookQtyCopy > 0) {
System.out.println("Book is Available.");
return i;
System.out.println("Book is Unavailable");
return -1;
on
}
System.out.println("No Book of Serial Number " + "Available in Library.");
dent
return -1;
// Method 9
Book
return theBooks[bookIndex];
001
return null;
// Method 10
Unavailable
for (int i = 0; i < count; i++) {
Practical Exercises
// Method 1
// Print statement
return;
// Method 2
// Displaying all students public void show AllStudents() {
// Method 3
{
// Display message only System.out.println("Enter Reg Number:");
if (theStudents[i].regNum.equalsIgnoreCase( regNum)) {
return i;
// Print statements
return -1;
// Method 4
// To remove the book
if (studentIndex != -1) {
System.out.println("checking out");
book.showAllBooks();
book bbook.checkOutBook();
if (theStudents[studentIndex].booksCount <= 3) {
System.out.println("adding book");
theStudents[studentIndex] borrowedBooks [theStudents[studentIndex]
booksCount] = b; theStudents[studentIndex].booksCount++;
return;
else {
System.out.println(
return;
Method 5
1
int studentIndex = this.isStudent(); if (student Index != -1) {
students theStudents[studentIndex];
edBooks
bunt++;
System.out.println(Count);
if (sNos.borrowedBooks[i].sNo) {
return;
}
E. File: Library.java
Java
import java.util.Scanner;
// Class
d In:");
System.out.println(
int choice;
int searchChoice;
// Creating menu
do {
ob.dispMenu();
choice = input.nextInt();
// Switch case
switch (choice) {
// Case
ob.addBook(b);
break;
// Case case 2:
ob.upgradeBookQty();
break;
// Case case 3:
System.out.println(
searchChoice = input.nextInt();
// Case
case 1: ob.searchBySno();
break;
// Case
case 2:
ob.searchByAuthorName();
break;
// Case
case 4:
ob.showAllBooks();
break;
// Case
case 5:
obStudent.addStudent(s);
break;
Book Ser
// Case
case 6:
Book's A nt();
obStudent.showAllStudents();
break;
// Case
case 7:
obStudent.checkOutBook(ob);
break;
// Case
case 8:
obStudent.checkInBook(ob);
break;
// Default case that will execute for sure
default:
// statement
}
Output:
Add Book
geekforgeek
geek
10
EEN STOL
90
Register Student
0001
checking out
S.No
Name
geekforgeek
App Development
Author
Available Qty
10
Book is Available.
Name
geek forgeek
Author
Available Qty
geek
Practical Exercises
0001
S.No
Book Name
geekforgeek
91
92
App Development
geek
neek 5.No
Name geekforgeek
Author
Available Qty 11
Total Qty 11
Show All The Registered Student
6
Student Name DragonUncaged