0% found this document useful (0 votes)
16 views77 pages

MAD Record

The document outlines a series of exercises focused on the installation and development of Android applications using Android Studio, including the use of UI toolkits, layout managers, and event listeners. Each exercise provides a step-by-step algorithm for creating mobile applications, demonstrating various components such as buttons, text views, and edit texts, along with Java code implementations. The results indicate successful execution of each application designed in the exercises.

Uploaded by

petri.success
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)
16 views77 pages

MAD Record

The document outlines a series of exercises focused on the installation and development of Android applications using Android Studio, including the use of UI toolkits, layout managers, and event listeners. Each exercise provides a step-by-step algorithm for creating mobile applications, demonstrating various components such as buttons, text views, and edit texts, along with Java code implementations. The results indicate successful execution of each application designed in the exercises.

Uploaded by

petri.success
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

[Link].

:1

INSTALLATION OF ANDROID STUDIO


Date :

Aim:

To implement mobile applications using ui toolkits and framework design an


application that uses layout managers and event listeners.

Algorithm:

STEP1:Open android studio and create new project


STEP2: Select our project in the project explorer
STEP3:Go to res folder and select layout Double click the main xml
file
STEP 4:Type the code for [Link] or drag and drop various
components used in our program
STEP 5:Drag and drop relative layout and change its properties
STEP 6 :Drag and drop image view and change its properties
according to our programs
STEP 7:Screen layout can be viewed by clicking graphics layout tab
STEP 8:Include necessary files
STEP 9:Override OnCreate() function
STEP 10:Create IImage view and initialize its using id of some
components used in the xml program
STEP 11:Save the program
STEP 12:Run the program
STEP 13:Output can be viewed in the android emulator

1
RESULT:
Thus, the installation of android studio has been successfully implemented
and executed.

2
[Link]. :2
IMPLEMENT MOBILE APPLICATIONS USING UI
TOOLKITS AND FRAMEWORK
Date :

Aim:
To implement mobile applications using ui toolkits and framework design an
application that uses layout managers and event listeners.

Algorithm:
STEP 1 :Open Android Stdio and then click on File -> New -> New
project.
STEP 2 : Design the layout on Avtivity [Link]
STEP 3 : Click on app -> java -> [Link]->
mainactivity.
STEP 4 :Impliment java code in the Main activity
STEP 5 : Start the Android emulator
STEP 6 : Build and compile the program

Program:

ACTIVITY MAIN. JAVA


<?Xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
Xmlns:app="[Link]
Xmlns:tools="[Link]
Android:layout_width="match_parent"
3
Android:layout_height="match_parent"
Tools:context=".mainactivity"
Tools:layout_editor_absolutex="0dp"
Tools:layout_editor_absolutey="1dp">

<edittext
Android:id="@+id/edittexttextpersonname2"
Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:ems="10"
Android:inputtype="textpersonname"
Android:text="hello there"
i
Tools:layout_editor_absolutey="26dp" />

<Button
Android:id="@+id/button"
Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:text="press here"
App:layout_constraintbottom_tobottomof="parent"
App:layout_constraintend_toendof="parent"
App:layout_constraintstart_tostartof="parent"
App:layout_constrainttop_totopof="parent" />
</[Link]>

4
MAIN ACTIVITY

Package [Link];

Import [Link];

Import [Link];
Import [Link];
Import [Link];
Import [Link];

Public class mainactivity extends appcompatactivity {


Textview Txt;
Button Btn;

@Override
Protected void oncreate(Bundle savedinstancestate) {
[Link](savedinstancestate);
Setcontentview([Link].activity_main);
Txt = findviewbyid([Link].edittexttextpersonname2);
Btn = findviewbyid([Link]);
[Link](new [Link]() {
@Override
Public void onclick(View v) {
[Link]("hello ");

5
}});}}

Output:

RESULT:

Thus, the python program to implement data preprocessing techniques on


real time datasethas been successfully implemented and executed.

6
[Link]. :3
DESIGN AN APPLiICATION THAT USES LAYOUT
MANAGERS AND EVENT LISTENERS
Date :

Aim:
To develop a Simple Android Application that uses Layout Managers and
Event Listeners.

Algorithm:
Creating a New project:
STEP 1 :Open Android Stdio and then click on File -> New -> New
project.
STEP 2:Then type the Application name as “[Link].2″ and click Next.
STEP 3 :Then select the Minimum SDK as shown below and click Next.
STEP 4 :Then select the Empty Activity and click Next.
STEP 5 :Finally click Finish.
STEP 6 :It will take some time to build and load the project.
STEP 7 :After completion it will look as given below.
Creating Second Activity for the Android Application:
STEP 1 :Click on File -> New -> Activity -> Empty Activity.
STEP 2 :Type the Activity Name as SecondActivity and click Finish button.
STEP 3 : Thus Second Activity For the application is created.
Designing layout for the Android Application:
Designing Layout for Main Activity:
STEP 4 :Click on app -> res -> layout -> activity_main.xml.
STEP 5 :Now click on Text as shown below.

7
STEP 6 :Then delete the code which is there and type the code as given below.
Program:
APP Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="[Link]

xmlns:tools="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

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

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

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"

<?xml version="1.0" encoding="utf-8"?>

<[Link]
xmlns:android="[Link]

xmlns:app="[Link]

xmlns:tools="[Link]

9
android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:id="@+id/setInformation"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.074" />

<Button

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="GET INFORMATION"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/setInformation"

app:layout_constraintVertical_bias="0.967" />

<TextView
10
android:id="@+id/ram"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="ramview"

app:layout_constraintBottom_toTopOf="@+id/button"

app:layout_constraintTop_toBottomOf="@+id/setInformation"

app:layout_constraintVertical_bias="0.925"

tools:layout_editor_absoluteX="0dp" />

</[Link]>

[Link]

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity {

TextView txt;
11
TextView ram;

Button btn;

long bytesAvailable,megAvailable;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main);

initView();

StatFs statFs = new


StatFs([Link]().getPath());

bytesAvailable =[Link]() *
[Link]();

megAvailable = bytesAvailable/ (1024*1024);

private void initView() {

txt= findViewById([Link]);

btn= findViewById([Link]);

ram=findViewById([Link]);

[Link](new [Link]() {

@Override

public void onClick(View v) {

String information= getHardwareAndSoftwareInfo();

[Link](information);

[Link](getMemoryinfo());

12
}

});

private String getMemoryinfo() {

Context context = getApplicationContext();

ActivityManager activityManager = (ActivityManager)


[Link](Context.ACTIVITY_SERVICE);

[Link] memoryInfo = new


[Link]();

[Link](memoryInfo);

DecimalFormat twoDecimalFormate = new DecimalFormat("#.##");

String finalvalue = "";

long totalMemory = [Link];

double kb = totalMemory / 1024.0;

double mb = totalMemory / 1048576.0;

double gb = totalMemory / 10737541824.0;

double tb = totalMemory / 1099511627776.0;

if (tb > 1) {
finalvalue = [Link](tb).concat("TB");

} else if (gb > 1) {

finalvalue = [Link](gb).concat("GB");

} else if (mb > 1) {

finalvalue = [Link](mb).concat("MB");

} else if (kb > 1) {

13
finalvalue = [Link](kb).concat("KB");

else

finalvalue =[Link](totalMemory).concat("Bytes");

StringBuilder stringBuilder = new StringBuilder();

[Link]("Ram: ").append(finalvalue).append("\n").

append("Available internal/external free space:" + megAvailable + "MB");

return [Link]();

private String getHardwareAndSoftwareInfo() {

return "Model"+" "+ [Link]+ "\n"+

"id" + " "+ [Link]+"\n"+

"manufacture" + " "+ [Link]+"\n"+

"Brand" + " "+ [Link]+"\n"+

"id" + " "+ [Link]+"\n" ;

14
Output:

RESULT:

Thus to design an appliication that uses layout managers and event listeners
Has been excuted sucessfully

15
[Link]. :4
DESIGN A MOBILE APPLICATION THAT IS
AWARE OF THE RESOURCE CONSTRAINTS OF
MOBILE DEVICES
Date :

Aim:

To develop an application that that is aware of the resource constraints of


mobile devices

Algorithm:

STEP 1: Add the Performance Monitoring SDK to your appIn your module
(app-level) Gradle file (usually <project>/<app-module>/[Link]), add the
dependency for the Performance Monitoring Android library

STEP 2: Add the Performance Monitoring Gradle plugin to your appIn your
root-level (project-level) Gradle file (<project>/[Link]), add the
Performance Monitoring Gradle plugin as a buildscript dependency:
Recompile your app

STEP 3: Generate performance events for initial data display

STEP 4 : calculate min and max available storage bytes

STEP 5: declare max sizes of the available ram double kb = totalMemory /


1024.0;

double mb = totalMemory / 1048576.0;

double gb = totalMemory / 10737541824.0;

double tb = totalMemory / 1099511627776.0;\

STEP 6 : Recompile the app

16
Program:

ACTIVITY MAIN

<?xml version="1.0" encoding="utf-8"?>

<AbsoluteLayout
xmlns:android="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="50dp"

android:layout_y="20dp"

android:text="Student Details"

android:textSize="30sp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="110dp"

android:text="Enter Rollno:"

android:textSize="20sp" />

<EditText

17
android:id="@+id/Rollno"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="100dp"

android:inputType="number"

android:textSize="20sp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="160dp"

android:text="Enter Name:"

android:textSize="20sp" />

<EditText

android:id="@+id/Name"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="150dp"

android:inputType="text"

android:textSize="20sp" />
18
<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="210dp"

android:text="Enter Marks:"

android:textSize="20sp" />

<EditText

android:id="@+id/Marks"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="200dp"

android:inputType="number"

android:textSize="20sp" />

<Button

android:id="@+id/Insert"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="25dp"

android:layout_y="300dp"
19
android:text="Insert"

android:textSize="30dp" />

<Button

android:id="@+id/Delete"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="200dp"

android:layout_y="300dp"

android:text="Delete"

android:textSize="30dp" />

<Button

android:id="@+id/Update"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="25dp"

android:layout_y="400dp"

android:text="Update"

android:textSize="30dp" />

<Button

android:id="@+id/View"

android:layout_width="150dp"
20
android:layout_height="wrap_content"

android:layout_x="200dp"

android:layout_y="400dp"

android:text="View"

android:textSize="30dp" />

<Button

android:id="@+id/ViewAll"

android:layout_width="200dp"

android:layout_height="wrap_content"

android:layout_x="100dp"

android:layout_y="500dp"

android:text="View All"

android:textSize="30dp" />

</AbsoluteLayout>

[Link]

package [Link].exno5;

import [Link];

import [Link];

import [Link];
21
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends Activity implements OnClickListener

EditText Rollno,Name,Marks;

Button Insert,Delete,Update,View,ViewAll;

SQLiteDatabase db;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState)

[Link](savedInstanceState);

setContentView([Link].activity_main);

Rollno=(EditText)findViewById([Link]);

Name=(EditText)findViewById([Link]);

Marks=(EditText)findViewById([Link]);

Insert=(Button)findViewById([Link]);
22
Delete=(Button)findViewById([Link]);

Update=(Button)findViewById([Link]);

View=(Button)findViewById([Link]);

ViewAll=(Button)findViewById([Link]);

[Link](this);

[Link](this);

[Link](this);

[Link](this);

[Link](this);

// Creating database and table

db=openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE,
null);

[Link]("CREATE TABLE IF NOT EXISTS student(rollno


VARCHAR,name VARCHAR,marks VARCHAR);");

public void onClick(View view)

// Inserting a record to the Student table

if(view==Insert)

// Checking for empty fields

if([Link]().toString().trim().length()==0||

23
[Link]().toString().trim().length()==0||

[Link]().toString().trim().length()==0)

showMessage("Error", "Please enter all values");

return;

[Link]("INSERT INTO student


VALUES('"+[Link]()+"','"+[Link]()+

"','"+[Link]()+"');");

showMessage("Success", "Record added");

clearText();

// Deleting a record from the Student table

if(view==Delete)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]())

24
{

[Link]("DELETE FROM student WHERE


rollno='"+[Link]()+"'");

showMessage("Success", "Record Deleted");

else

showMessage("Error", "Invalid Rollno");

clearText();

// Updating a record in the Student table

if(view==Update)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]()) {

[Link]("UPDATE student SET name='" + [Link]() +


"',marks='" + [Link]() +
25
"' WHERE rollno='"+[Link]()+"'");

showMessage("Success", "Record Modified");

else {

showMessage("Error", "Invalid Rollno");

clearText();

// Display a record from the Student table

if(view==View)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]())

[Link]([Link](1));

[Link]([Link](2));

}
26
else

showMessage("Error", "Invalid Rollno");

clearText();

// Displaying all the records

if(view==ViewAll)

Cursor c=[Link]("SELECT * FROM student", null);

if([Link]()==0)

showMessage("Error", "No records found");

return;
}

StringBuffer buffer=new StringBuffer();

while([Link]())

[Link]("Rollno: "+[Link](0)+"\n");

[Link]("Name: "+[Link](1)+"\n");

[Link]("Marks: "+[Link](2)+"\n\n");

showMessage("Student Details", [Link]());

}
27
}

public void showMessage(String title,String message)

Builder builder=new Builder(this);

[Link](true);

[Link](title);

[Link](message);

[Link]();

public void clearText()

[Link]("");

[Link]("");

[Link]("");

[Link]();

28
Output:

RESULT:

thus to design a mobile application that is aware of the resource constraints


of mobile devices has been completed successfully.

29
[Link]. :5
DESIGN AN APPLICATION THAT USES DYNAMIC
LINKING
Date :

Aim:

To Designan application that uses dynamic linking

Algorithm:

STEP 1 :Create a new project in the firebase by clicking on the Add


[Link] open the android studio and click on Tools in the upper
leftcorner

STEP 2 :Now click on the Firebase option in the drop down menu.

STEP 3 :A menu will appear on the right side of screen. It will show
variousservices that Firebase offers. Choose the desired service.

STEP 4 :Now Click on the Connect to Firebase option in the menu of


desired service.

Add the dependencies of your service by clicking on the Add [YOUR


SERVICE NAME] to the app option. (In the image below, the
Firebase cloud messaging service is chosen)

In this, the steps involve:

STEP 5 :Create a firebase projectII41

STEP 6 :Create a project by clicking on create project in the firebase


console

Click on create project to finally create it.

STEP 7 :Now add this project to the android app

Click on the Add firebase to your android app option on the


starting window.
30
Now add the following in the project.

• Adding the sdk in the project.

STEP 8 :Add the following code to the [Link] of the


app.

buildscript {

dependencies {

classpath '[Link]:google-services:4.0.0'

• Add the following code to APP-LEVEL [Link] of the app.

dependencies {

compile '[Link]:firebase-core:16.0.0'

...

// Add to the bottom of the file

apply plugin: '[Link]-services'

STEP 9 :Now Sync the gradle by clicking on sync now.

STEP 10 :After adding the above code(sdk), run the app to send the
verification to the Firebase console.

31
Program:

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class DynamicLinksActivity extends AppCompatActivity {

private Uri dynamicLink = null;

private static final String TAG = "DynamicLinks";

public void getLink(View view) {

String appCode = "<app_code>";

final Uri deepLink = [Link]("[Link]

String packageName = getApplicationContext().getPackageName();

// Build the link with all required parameters

[Link] builder = new [Link]()

.scheme("https")

.authority(appCode + ".[Link]")

.path("/")

.appendQueryParameter("link", [Link]())

.appendQueryParameter("apn", packageName);

32
dynamicLink = [Link]();

[Link](true);

Output:

RESULT:

Thus to design an application that uses dynamic linking Has been

excuted sucessfully

33
[Link]. :6
DEVELOP AN APPLICATION THAT MAKES USE OF
MOBILE DATABASE
Date :

Aim:

To develop a Simple Android Application that makes use of


Database.

Algorithm:

STEP1:Open eclipse or android studio and create new project


STEP2: Select our project in the project explorer
STEP3:Go to res folder and select layout Double click the main xml file
STEP 4:Type the code for [Link] or drag and drop various components
used in our program
STEP 5:Drag and drop absloute layout and change its properties
STEP 6 :Drag and drop image view and change its properties according to
our programs
STEP 7:we are using sql data base for the program
STEP 8:Include necessary files
STEP 9:Override OnCreate() function
STEP 10:Create a data base and import
STEP 11:Save the program
STEP 12:Run the program
STEP 13:Output can be viewed in the android emulator

34
Program:

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<AbsoluteLayout
xmlns:android="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="50dp"

android:layout_y="20dp"

android:text="Student Details"

android:textSize="30sp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="110dp"

android:text="Enter Rollno:"

android:textSize="20sp" />

<EditText

35
android:id="@+id/Rollno"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="100dp"

android:inputType="number"

android:textSize="20sp" />

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="160dp"

android:text="Enter Name:"

android:textSize="20sp" />

<EditText

android:id="@+id/Name"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="150dp"

android:inputType="text"

android:textSize="20sp" />
36
<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="20dp"

android:layout_y="210dp"

android:text="Enter Marks:"

android:textSize="20sp" />

<EditText

android:id="@+id/Marks"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="175dp"

android:layout_y="200dp"

android:inputType="number"

android:textSize="20sp" />

<Button

android:id="@+id/Insert"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="25dp"

android:layout_y="300dp"
37
android:text="Insert"

android:textSize="30dp" />

<Button

android:id="@+id/Delete"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="200dp"

android:layout_y="300dp"

android:text="Delete"

android:textSize="30dp" />

<Button

android:id="@+id/Update"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_x="25dp"

android:layout_y="400dp"

android:text="Update"

android:textSize="30dp" />

<Button

android:id="@+id/View"

android:layout_width="150dp"
38
android:layout_height="wrap_content"

android:layout_x="200dp"

android:layout_y="400dp"

android:text="View"

android:textSize="30dp" />

<Button

android:id="@+id/ViewAll"

android:layout_width="200dp"

android:layout_height="wrap_content"

android:layout_x="100dp"

android:layout_y="500dp"

android:text="View All"

android:textSize="30dp" />

</AbsoluteLayout>

MAIN ACTIVITY

package [Link].exno5;

import [Link];

import [Link];

import [Link];

import [Link];
39
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends Activity implements OnClickListener

EditText Rollno,Name,Marks;

Button Insert,Delete,Update,View,ViewAll;

SQLiteDatabase db;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState)

[Link](savedInstanceState);

setContentView([Link].activity_main);

Rollno=(EditText)findViewById([Link]);

Name=(EditText)findViewById([Link]);

Marks=(EditText)findViewById([Link]);

Insert=(Button)findViewById([Link]);

Delete=(Button)findViewById([Link]);
40
Update=(Button)findViewById([Link]);

View=(Button)findViewById([Link]);

ViewAll=(Button)findViewById([Link]);

[Link](this);

[Link](this);

[Link](this);

[Link](this);

[Link](this);

// Creating database and table

db=openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE,
null);

[Link]("CREATE TABLE IF NOT EXISTS student(rollno


VARCHAR,name VARCHAR,marks VARCHAR);");

public void onClick(View view)

// Inserting a record to the Student table

if(view==Insert)
{

// Checking for empty fields

if([Link]().toString().trim().length()==0||

[Link]().toString().trim().length()==0||

41
[Link]().toString().trim().length()==0)

showMessage("Error", "Please enter all values");

return;

[Link]("INSERT INTO student


VALUES('"+[Link]()+"','"+[Link]()+

"','"+[Link]()+"');");

showMessage("Success", "Record added");

clearText();

// Deleting a record from the Student table

if(view==Delete)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]())

42
[Link]("DELETE FROM student WHERE
rollno='"+[Link]()+"'");

showMessage("Success", "Record Deleted");

else

showMessage("Error", "Invalid Rollno");

clearText();

// Updating a record in the Student table

if(view==Update)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]()) {

[Link]("UPDATE student SET name='" + [Link]() +


"',marks='" + [Link]() +

"' WHERE rollno='"+[Link]()+"'");


43
showMessage("Success", "Record Modified");

else {

showMessage("Error", "Invalid Rollno");

clearText();

// Display a record from the Student table

if(view==View)

// Checking for empty roll number

if([Link]().toString().trim().length()==0)

showMessage("Error", "Please enter Rollno");

return;

Cursor c=[Link]("SELECT * FROM student WHERE


rollno='"+[Link]()+"'", null);

if([Link]())

[Link]([Link](1));

[Link]([Link](2));

else

44
{

showMessage("Error", "Invalid Rollno");

clearText();

// Displaying all the records

if(view==ViewAll)

Cursor c=[Link]("SELECT * FROM student", null);

if([Link]()==0)

showMessage("Error", "No records found");

return;

StringBuffer buffer=new StringBuffer();

while([Link]())

[Link]("Rollno: "+[Link](0)+"\n");

[Link]("Name: "+[Link](1)+"\n");

[Link]("Marks: "+[Link](2)+"\n\n");

showMessage("Student Details", [Link]());

}
45
public void showMessage(String title,String message)

Builder builder=new Builder(this);

[Link](true);

[Link](title);

[Link](message);

[Link]();

public void clearText()

[Link]("");

[Link]("");

[Link]("");

[Link]();

46
Output:

RESULT:

Thus, to develop an application that makes use of mobile database. Has been

excuted sucessfully

47
[Link]. :7
IMPLEMENT AN APPLICATION THAT WRITES
DATA TO THE SD CARD.
Date :

Aim:

Implement an application that writes data to the SD card.

Algorithm:

STEP1:Open eclipse or android studio and create new project


STEP2: Select our project in the project explorer
STEP3:Go to res folder and select layout Double click the main xml file
STEP 4:Type the code for [Link] or drag and drop various components
used in our program
STEP 5:Drag and drop relative layout and change its properties
STEP 6 :Drag and drop image view and change its properties according to
our programs
STEP 7:Screen layout can be viewed by clicking graphics layout tab
STEP 8:Include necessary files
STEP 9:Override OnCreate() function
STEP 10:Create Image view and initialize its using id of some components
used in the xml program
STEP 11:Save the program
STEP 12:Run the program
STEP 13:Output can be viewed in the android emulator

48
Program:

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="20dp"

android:orientation="vertical">

<EditText

android:id="@+id/editText"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:singleLine="true"

android:textSize="30dp" />

<Button

android:id="@+id/button"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="10dp"

android:text="Write Data"

android:textSize="30dp" />

49
<Button

android:id="@+id/button2"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="10dp"

android:text="Read data"

android:textSize="30dp" />

<Button

android:id="@+id/button3"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="10dp"

android:text="Clear"

android:textSize="30dp" />

</LinearLayout>

[Link]

package [Link].exno9;

import [Link];

import [Link];

import [Link];

import [Link];
50
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity

EditText e1;

Button write,read,clear;

@Override

protected void onCreate(Bundle savedInstanceState)

[Link](savedInstanceState);

setContentView([Link].activity_main);

e1= (EditText) findViewById([Link]);

write= (Button) findViewById([Link]);

read= (Button) findViewById([Link].button2);

clear= (Button) findViewById([Link].button3);

51
[Link](new [Link]()

@Override

public void onClick(View v)

String message=[Link]().toString();

try

File f=new File("/sdcard/[Link]");

[Link]();

FileOutputStream fout=new FileOutputStream(f);

[Link]([Link]());

[Link]();

[Link](getBaseContext(),"Data Written in
SDCARD",Toast.LENGTH_LONG).show();

catch (Exception e)

{
[Link](getBaseContext(),[Link](),Toast.LENGTH_LONG).sh
ow();

});

[Link](new [Link]()
52
{

@Override

public void onClick(View v)

String message;

String buf = "";

try

File f = new File("/sdcard/[Link]");

FileInputStream fin = new FileInputStream(f);

BufferedReader br = new BufferedReader(new


InputStreamReader(fin));

while ((message = [Link]()) != null)

buf += message;

[Link](buf);

[Link]();

[Link]();

[Link](getBaseContext(),"Data Recived from


SDCARD",Toast.LENGTH_LONG).show();

catch (Exception e)

53
[Link](getBaseContext(), [Link](),
Toast.LENGTH_LONG).show();

});

[Link](new [Link]()

@Override

public void onClick(View v)

[Link]("");

});

}package [Link].exno9;

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

54
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity

EditText e1;

Button write,read,clear;

@Override

protected void onCreate(Bundle savedInstanceState)

[Link](savedInstanceState);

setContentView([Link].activity_main);

e1= (EditText) findViewById([Link]);

write= (Button) findViewById([Link]);

read= (Button) findViewById([Link].button2);

clear= (Button) findViewById([Link].button3);

[Link](new [Link]()

@Override
55
public void onClick(View v)

String message=[Link]().toString();

try

File f=new File("/sdcard/[Link]");

[Link]();

FileOutputStream fout=new FileOutputStream(f);

[Link]([Link]());

[Link]();

[Link](getBaseContext(),"Data Written in
SDCARD",Toast.LENGTH_LONG).show();

catch (Exception e)

[Link](getBaseContext(),[Link](),Toast.LENGTH_LONG).sh
ow();

});

[Link](new [Link]()

@Override
56
public void onClick(View v)

String message;

String buf = "";

try

File f = new File("/sdcard/[Link]");

FileInputStream fin = new FileInputStream(f);

BufferedReader br = new BufferedReader(new


InputStreamReader(fin));

while ((message = [Link]()) != null)

buf += message;

[Link](buf);

[Link]();

[Link]();

[Link](getBaseContext(),"Data Recived from


SDCARD",Toast.LENGTH_LONG).show();

catch (Exception e)

[Link](getBaseContext(), [Link](),
Toast.LENGTH_LONG).show();
}
57
}

});

[Link](new [Link]()

@Override

public void onClick(View v)

[Link]("");

});

58
Output:

RESULT:

Thus to implement an application that writes data to the sd card. Has


been excuted sucessfully

59
[Link]. :8
DEVELOP A WEB BASED MOBILE APPLICATION
THAT ACCESSES INTERNET AND LOCATION
DATA
Date :

Aim:

To develop a Android Application that writes data to the SD Card.

Algorithm:

STEP1:Open eclipse or android studio and create new project


STEP2: Select our project in the project explorer
STEP3:Go to res folder and select layout Double click the main xml file
STEP 4:Type the code for [Link] or drag and drop various components
used in our program
STEP 5:Drag and drop relative layout and change its properties
STEP 6 :Drag and drop image view and change its properties according to
our programs
STEP 7:Screen layout can be viewed by clicking graphics layout tab
STEP 8:Include necessary files
STEP 9:Override OnCreate() function
STEP 10:Create Image view and initialize its using id of some components
used in the xml program
STEP 11:Save the program
STEP 12:Run the program
STEP 13:Output can be viewed in the android emulator

60
Program:

Activity_main.xml

<?xml version = "1.0" encoding = "utf-8"?>

<LinearLayout xmlns:android =
"[Link]

android:layout_width = "fill_parent"

android:layout_height = "fill_parent"

android:orientation = "vertical" >

<Button

android:id = "@+id/button"

android:layout_width = "fill_parent"

android:layout_height = "wrap_content"

android:text = "getlocation"/>

</LinearLayout>

MAIN ACTIVITY

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

61
import [Link];

import [Link];

import [Link];

import [Link];

public class GPSTracker extends Service implements LocationListener {

private final Context mContext;

// flag for GPS status

boolean isGPSEnabled = false;

// flag for network status

boolean isNetworkEnabled = false;

// flag for GPS status

boolean canGetLocation = false;

Location location; // location

double latitude; // latitude

double longitude; // longitude

// The minimum distance to change Updates in meters

62
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES =
10; // 10 meters

// The minimum time between updates in milliseconds

private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1


minute

// Declaring a Location Manager

protected LocationManager locationManager;

public GPSTracker(Context context) {

[Link] = context;

getLocation();

public Location getLocation() {

try {

locationManager = (LocationManager)
[Link](LOCATION_SERVICE);

// getting GPS status

isGPSEnabled =
[Link](LocationManager.GPS_PROVIDER);

// getting network status

63
isNetworkEnabled = locationManager

.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

if (!isGPSEnabled && !isNetworkEnabled) {

// no network provider is enabled

} else {

[Link] = true;

// First get location from Network Provider

if (isNetworkEnabled) {

[Link](

LocationManager.NETWORK_PROVIDER,

MIN_TIME_BW_UPDATES,

MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

Log.d("Network", "Network");

if (locationManager != null) {

location = locationManager

.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

if (location != null) {

latitude = [Link]();

longitude = [Link]();

64
}

// if GPS Enabled get lat/long using GPS Services

if (isGPSEnabled) {

if (location == null) {

[Link](

LocationManager.GPS_PROVIDER,

MIN_TIME_BW_UPDATES,

MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

Log.d("GPS Enabled", "GPS Enabled");

if (locationManager != null) {

location = locationManager

.getLastKnownLocation(LocationManager.GPS_PROVIDER);

if (location != null) {

latitude = [Link]();

longitude = [Link]();

}
65
} catch (Exception e) {

[Link]();

return location;

/**

* Stop using GPS listener

* Calling this function will stop using GPS in your app

* */

public void stopUsingGPS(){

if(locationManager != null){

[Link]([Link]);

/**

* Function to get latitude

* */

public double getLatitude(){

if(location != null){

latitude = [Link]();

// return latitude
66
return latitude;

/**

* Function to get longitude

* */

public double getLongitude(){

if(location != null){

longitude = [Link]();

// return longitude

return longitude;

/**

* Function to check GPS/wifi enabled

* @return boolean

* */

public boolean canGetLocation() {

return [Link];

/**

* Function to show settings alert dialog

* On pressing Settings button will lauch Settings Options

* */
67
public void showSettingsAlert(){

[Link] alertDialog = new [Link](mContext);

// Setting Dialog Title

[Link]("GPS is settings");

// Setting Dialog Message

[Link]("GPS is not enabled. Do you want to go to


settings menu?");

// On pressing Settings button

[Link]("Settings", new
[Link]() {

public void onClick(DialogInterface dialog,int which) {

Intent intent = new


Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);

[Link](intent);

});

// on pressing cancel button

[Link]("Cancel", new
[Link]() {

public void onClick(DialogInterface dialog, int which) {

[Link]();

});

// Showing Alert Message

[Link]();

68
}

@Override

public void onLocationChanged(Location location) {

@Override

public void onProviderDisabled(String provider) {

@Override

public void onProviderEnabled(String provider) {

@Override

public void onStatusChanged(String provider, int status, Bundle extras) {

@Override

public IBinder onBind(Intent arg0) {

return null;

69
Output:

RESULT:

thus to develop a web based mobile application that accesses internet


and location data Has been excuted sucessfully

70
[Link]. :9
DEVELOP AN ANDROID APPLICATION USING
TELEPHONY TO SEND SMS
Date :

Aim:

To develop an android application using telephony to send sms.

Algorithm:

STEP1:Open eclipse or android studio and create new project


STEP2: Select our project in the project explorer
STEP3:Go to res folder and select layout Double click the main xml file
STEP 4:Type the code for [Link] or drag and drop various components
used in our program
STEP 5:Drag and drop relative layout and change its properties
STEP 6 :Drag and drop image view and change its properties according to
our programs
STEP 7:Screen layout can be viewed by clicking graphics layout tab
STEP 8:Include necessary files
STEP 9:Override OnCreate() function
STEP 10:Create IImage view and initialize its using id of some components
used in the xml program
STEP 11:Save the program
STEP 12:Run the program
STEP 13:Output can be viewed in the android emulator

71
Program:

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="[Link]

xmlns:tools="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

android:paddingBottom="@dimen/activity_vertical_margin"

toIols:context=".MainActivity">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Drag and Drop Example"

android:id="@+id/textView"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:textSize="30dp" />

<TextView

android:layout_width="wrap_content"
72
android:layout_height="wrap_content"

android:text="Tutorials Point "

android:id="@+id/textView2"

android:layout_below="@+id/textView"

android:layout_centerHorizontal="true"

android:textSize="30dp"

android:textColor="#ff14be3c" />

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/imageView"

android:src="@drawable/abc"

android:layout_marginTop="48dp"

android:layout_below="@+id/textView2"

android:layout_centerHorizontal="true" />

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Compose SMS"

android:id="@+id/button"

android:layout_below="@+id/imageView"

android:layout_alignRight="@+id/textView2"
73
android:layout_alignEnd="@+id/textView2"

android:layout_marginTop="54dp"

android:layout_alignLeft="@+id/imageView"

android:layout_alignStart="@+id/imageView" />

</RelativeLayout>

MAIN ACTIVITY :

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);
74
setContentView([Link].activity_main);

Button startBtn = (Button) findViewById([Link]);

[Link](new [Link]() {

public void onClick(View view) {

sendSMS();

});

protected void sendSMS() {

Log.i("Send SMS", "");

Intent smsIntent = new Intent(Intent.ACTION_VIEW);

[Link]([Link]("smsto:"));

[Link]("[Link]-dir/mms-sms");

[Link]("address" , new String ("01234"));

[Link]("sms_body" , "Test ");

try {

startActivity(smsIntent);

finish();

Log.i("Finished sending SMS...", "");

} catch ([Link] ex) {


75
[Link]([Link],

"SMS faild, please try again later.", Toast.LENGTH_SHORT).show();

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate([Link], menu);

return true;

76
\Output:

RESULT:

thus, to develop an android application using telephony to send sms. Has been

excuted successful.

77

You might also like