Mad 4-1 r22 2026 NEW
Mad 4-1 r22 2026 NEW
LAB MANUAL
SubjectCode : AM734PE
Regulation: R22/JNTUH
Academic Year: 2024-2025
Faculty :
IV B.TECH I SEMESTER
AAR MAHAVEERENGINEERING COLLEGE (8P) AffiliatedoJNTUH,Vyasapuri,
(V),Bandlaguda(M)R.RDist,TS-500005
2
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
MOBILE APPLICATION
DEVELOPMENT LAB
LAB MANUAL
DEPARTMENT OFCOMPUTER SCIENCE AND
ENGINEERING (AIML)
B.TECH(R-22Regulation)
(IV YEAR – I SEM)
2024-25
3
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
To facilitate the graduates with the technical skills that prepare them for
immediate employment and pursue certification providing a deeper understanding
of the technology in advanced areas of computer science and related fields, thus
encouraging to pursue higher education and research based on their interest.
To facilitate the graduates with the soft skills that include fulfilling the
mission, setting goals, showing self-confidence by communicating effectively, having
a positive attitude, get involved in team-work, being a leader, managing their career
and their life.
After the completion of the course, B. Tech Computer Science and Engineering,
the graduates will have the following Program Specific Outcomes:
1. Fundamentals and critical knowledge of the Computer System:- Able
to Understand the working principles of the computer System and its
components , Apply the knowledge to build, asses, and analyze the
software and hardware aspects of it .
2. The Comprehensive and Applicative knowledge of Software
Development: Comprehensive skills of Programming Languages,
Software process models, methodologies, and able to plan, develop, test,
analyze, and manage the software and hardware intensive systems in
heterogeneous platforms individually or working in teams.
3. Applications of Computing Domain & Research: Able to use the
professional, managerial, interdisciplinary skill set, and domain specific
tools in development processes, identify the research gaps, and provide
innovative solutions to them.
5
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
3. Design / development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms
of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life- long learning: Recognize the need for, and have the preparation and ability to engage in independent
and life-long learning in the broadest context of technological change.
6
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
1. Students are advised to come to the laboratory at least 5 minutes before (to the starting
time), those who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the lab with
the synopsis / program / experiment details.
3. Student should enter into the laboratory with:
a. Laboratory observation notes with all the details (Problem statement, Aim, Algorithm,
Procedure, Program, Expected Output, etc.,) filled in for the lab session.
b. Laboratory Record updated up to the last session experiments and other utensils (if any)
needed in the lab.
c. Proper Dress code and Identity card.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the computer system allotted
to you by the faculty.
5. Execute your task in the laboratory, and record the results/output in the lab observation note
book, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratory staff, must maintain
the discipline and decency in the laboratory.
7. Computer labs are established with sophisticated and high end branded systems, which should
be utilized properly.
8. Students/Faculty must keep their mobile phones in SWITCHED OFF mode during the lab sessions.
Misuse of the equipment, misbehaviors with the staff and systems etc., will attract severe
punishment.
9. Students must take the permission of the faculty in case of any urgency to go out; if anybody found
loitering outside the lab / class without permission during working hours will be treated seriously
and punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she leaves the lab
after completing the task (experiment) in all aspects. He/she must ensure the system/seat is kept
properly.
COURSE OBJECTIVES:
Students will be able to:
List of Experiments
1. Installation of Android Studio.
3. Create an application that takes the name from a text box and shows hello message
along with the name entered in text box, when the user clicks the OK button.
4. Create a screen that has input boxes for UserName, Password, Address, Gender
(radio buttons for male and female), Age(numeric),Date of Birth(DatePicket), State
(Spinner) and a Submit button. On clicking the submit button, print all the data below
the Submit Button (use any layout).
5. Design an android application to create page using Intent and one Button and pass
the Values from one Activity to second Activity.
6. Design an android application Send SMS using Intent.
7. Create an android application using Fragments.
8. Design an android application Using Radio buttons.
9. Design an android application for menu.
10. Create a user registration application that stores the user details in a database table.
8
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
TEXTBOOKS:
1. Professional Android 4 Application Development, Reto Meier,Wiley India,(Wrox),2012
2. Android Application Development for Java Programmers, James
C Sheusi,Cengage Learning,2013
REFERENCES:
1. Beginning Android 4 Application Development, Wei-Meng Lee, Wiley
India(Wrox),2013
2. Android Application Development (with Kitkat Support), Black
Book,PradeepKothari,2014,DreamtechPresspublisher,KogentLearningInc.,2014
3. Android Programming: Pushing the Limits, Erik Hellman, 1st
Edition,WileyPublications,2014
COURSE OUTCOMES:
1. The Mobile Application Development course exposes the students to the essentials of
mobile app development using Android Operating System.
2. The core modules of this subject include designing, developing, testing, signing, packaging
and distributing high-quality mobile apps.
3. This course aims to teach mobile app development using Android as the development
platform.
9
AAR MAHAVEER ENGINEERING COLLEGE (8P)
(Approved by AICTE, Affiliated to JNTU , Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Table of Contents
Once you launched Android Studio, its time to mention JDK7 path or later version in android
studio installer.
1
2
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Need to check the components, which are required to create applications, below the image has
selected Android Studio, Android SDK, Android Virtual Machine and performance(Intel chip).
2
3
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Need to specify the location of local machine path for Android studio and Android SDK, below
the image has taken default location of windows 8.1 x64 bit architecture.
Need to specify the ram space for Android emulator by default it would take 512MB of local
machine RAM.
3
4
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
At final stage, it would extract SDK packages into our local machine, it would take a while time
to finish the task and would take 2626MB of Hard disk space.
After done all above steps perfectly, you must get finish button and it gonna be open android
studio project with Welcome to android studio message as shown below
4
5
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
You can start your application development by calling start a new android studio project. in a new
installation frame should ask Application name, package information and location of the project.
After entered application name, it going to be called select the form factors your application runs
on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android
6.0(Marshmallow)
5
6
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications
At the final stage it going to be open development tool to write the application code.
6
7
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
To test your Android applications, you will need a virtual Android device. So before we start
writing our code, let us create an Android virtual device. Launch Android AVD Manager Clicking
AVD_ Manager icon as shown below
After Click on a virtual device icon, it going to be shown by default virtual devices which
are present on your SDK, or else need to create a virtual device by clicking Create new
7
8
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Virtual device button
If your AVD is created successfully it means your environment is ready for Android application
development. If you like, you can close this window using top-right cross button. Better you re- start your
machine and once you are done with this last step, you are ready to proceed for your first Android example but
before that we will see few more important concepts related to Android Application Development.
8
9
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
If your AVD is created successfully it means your environment is ready for Android application development.
If you like, you can close this window using top-right cross button. Better you re- start your machine and once
you are done with this last step, you are ready to proceed for your first Android example but before that we will
see few more important concepts related to Android Application Development.
Exercise Program
1. Write the steps in installing Android Studio in Windows and Linux.
9
10
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
10
11
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO: 2
You can start your application development by calling start a new android
studio project.
In a newinstallation frame should ask Application name, package
information and location of the project.
11
12
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Change the name of the application. Change the default Project location to your preferred
directory or just leave it as the default location.
On the minimum API level, ensure that API 15: Android 4.0.3 IceCreamSandwich is set as the
Minimum SDK. This ensures that your application runs on almost all devices.
12
13
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
The next level of installation should contain selecting the activity to mobile, it specifies the
defaultlayout for Applications.
13
14
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
SOURCE CODE :
The Main Activity File
The main activity code is a Java file MainActivity.java. This is the actual application file which
ultimately gets converted to a Dalvik executable and runs your application
import
androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
Plug in your device to your computer with a USB cable. If you're developing on Windows,
you might need to install this universal ADB USB driver or find your specific USB driver for
14
15
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
your device.
15
16
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
The next step is to enable USB debugging so your phone can interact with your computer in a developer
mode.
1. Select one of your projects and click "Run" from the toolbar.
2. In the "Choose Device" window that appears, select the "Choose a running device" radio button,
select the device, and click OK.
To run the app from Android studio, open one of your project's activity files and click Run icon from
the tool bar. Android studio installs the app on your AVD and starts it and if everything is fine with your
set-up and application, it will display following Emulator window −Once Gradle finishes building,
Android Studio should install the app on your connected device and start it.
16
17
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
OUTPUT:
Exercise Program:
1 .Design an android application to display Name, Class, College , Address etc of a student.
17
18
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
18
19
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO : 3
Create an application that takes the name from a text box and shows hello message along with the name
entered in text box, when the user clicks the OK button.
AIM: To Create an application that takes the name from a text box and shows hello message along with the
name entered in text box, when the user clicks the OK button.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Override
public void onClick(View v) {
String name = editName.getText().toString();
String password = editPassword.getText().toString();
result.setText("Name:\t" + name + "\nPassword:\t" + password );
19
20
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
20
21
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
});
/*
Reset Button
*/
buttonReset.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{ editName.setText("");
editPassword.setText("");
result.setText("");
editName.requestFocus();
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#FFFF8D"
tools:context="com.example.akshay.mrcet.MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="NAME"
android:textSize="20sp"
android:layout_margin="20dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="PASSWORD"
android:layout_marginTop="38dp"
android:layout_below="@+id/textView"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" /
>
21
22
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
<EditText android:id="@+id/editName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Enter Name"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="@+id/editPassword"
android:layout_alignStart="@+id/editPassword" /
>
<EditText
android:id="@+id/editPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter Password"
android:inputType="textPassword"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="18dp"
android:layout_marginEnd="18dp" />
<Button android:id="@+id/buttonSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="20dp"
android:text="SUBMIT" />
<Button
android:id="@+id/buttonReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RESET"
android:layout_alignBaseline="@+id/buttonSubmit"
android:layout_alignBottom="@+id/buttonSubmit"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/tvResult"
android:layout_width="wrap_content"
22
23
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="143dp"
android:textSize="30sp" />
</RelativeLayout>
OUTPUT:
Exercise Program:
1. Design an android application to read Employee details from text boxes and display when
clicked on submit button.
23
24
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
24
25
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO. : 4
Create a screen that has input boxes for User Name, Password, Address, Gender(radio buttons for
male and female), Age (numeric) and a Submit button. On clicking the submit button, print all the data
below the Submit Button (use any layout)
AIM: To Create a screen that has input boxes for User Name, Password, Address, Gender(radio buttons for
male and female), Age (numeric) and a Submit button. On clicking the submit button, print all the data below
the Submit Button (use any layout).
Package com.example.week4;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import
android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username1 = (EditText) findViewById(R.id.username);
password1=(EditText)findViewById(R.id.password);
address1=(EditText)findViewById(R.id.address);
age1=(EditText)findViewById(R.id.age);
group1=(RadioGroup)findViewById(R.id.group);
output1=(TextView)findViewById(R.id.output);
submit1=(Button)findViewById(R.id.submit);
submit1.setOnClickListener(new View.OnClickListener()
25
26
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
{
@Override
public void onClick(View view) {
26
27
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
String username2 = username1.getText().toString();
String password2 =
password1.getText().toString(); String address2=
address1.getText().toString(); String age2 =
age1.getText().toString();
int selectid1= group1.getCheckedRadioButtonId();
RadioButton radioButton2 = (RadioButton) findViewById(selectid1);
output1.setText(username2+"\n"+password2+"\n"+address2+"\n"+age2+"\n"+ radioButton2);
}
});
}
}
Excersise program:
1. Create a screen that has input boxes for User Name, Password, Address, Gender(radio buttons for male
and female), Age (numeric), Date of Birth (Date Picket), State (Spinner) and a Submit button. On
clicking the submit button, print all the data below the Submit Button (use any layout)
27
28
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes:
28
29
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO : 5
Design an android application to create page using Intent and one Button and pass the Values from
One Activity to second Activity.
AIM: To design an android application to design a page using Intent and one Button and pass the
Values from one Activity to second Activity.
Main Activity Java File
package com.example.week5;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
send_button=(Button)
findViewById(R.id.send_button); send_text=(EditText)
findViewById(R.id.send_text);
send_button.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View view) {
String str = send_text.getText().toString();
Intent intent = new Intent(getApplicationContext(),second2.class);
intent.putExtra("message_key",str);
startActivity(intent);
}
});
}
}
package com.example.week5;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
29
30
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
public class second2 extends AppCompatActivity
{ TextView receive_msg;
30
31
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
receive_msg=(TextView) findViewById(R.id.output);
Intent intent = getIntent();
String str = intent.getStringExtra("message_key");
receive_msg.setText(str);
}
OUTPUT:
Exercise Program:
1.Design an android application to create page using Intent and one Button and pass the Values from
one Activity to second Activity and then to the Third activity.
31
32
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
32
33
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
33
34
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO: 6
MainActivity.java
package com.example.week6;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
35
36
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
ActivityCompat.requestPermissions(this,new String[]{
Manifest.permission.SEND_SMS},MY_PERMISSION_REQUEST_SEND_SMS)
;
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode,String permissions[],int[] grantResult) {
switch (requestCode){
case MY_PERMISSION_REQUEST_SEND_SMS : {
if(grantResult.length > 0 && grantResult[0]==PackageManager.PERMISSION_GRANTED)
{ SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneno,null,message,null,null);
Toast.makeText(getApplicationContext(),"SMS SENT",Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(),"SMS FAILED TRY
AGAIN",Toast.LENGTH_LONG).show();
return;
}
}
}
}
}
OUTPUT:
36
37
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
37
38
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO: 7
Create an android application using Fragments
AIM: To Create an android application using Fragments.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android
" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="example.javatpoint.com.fragmentexample.MainActivity">
<fragment
android:id="@+id/fragment1"
android:name="example.javatpoint.com.fragmentexample.Frag
ment1"android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<fragment
android:id="@+id/fragment2"
android:name="example.javatpoint.com.fragmentexample.Fragment2"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
fragment_fragment1.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5DC"
tools:context="example.javatpoint.com.fragmentexample.Fragment1">
</FrameLayout>
File: fragment_fragment2.xml
38
39
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android
" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0FFFF"
tools:context="example.javatpoint.com.fragmentexample.Fragment2"
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
File: Fragment1.java
package example.javatpoint.com.fragmentexample;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
39
40
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_fragment1, container, false);
40
41
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
}
}
File: Fragment2.java
package example.javatpoint.com.fragmentexample;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends Fragment
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_fragment2, container, false);
}
}
OUTPUT:
41
42
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
42
43
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO: 8
MainActivity.java
package com.example.radiobutton;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import
android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity
{
private RadioGroup radioGroup;
private RadioButton sound, vibration, silent;
private Button button;
private TextView
textView;@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radioGroup = (RadioGroup) findViewById(R.id.myRadioGroup);
radioGroup.setOnCheckedChangeListener(new
OnCheckedChangeListener()
{
@Override
43
44
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
public void onCheckedChanged(RadioGroup group, int checkedId)
{
44
45
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
if(checkedId == R.id.silent)
{
Toast.makeText(getApplicationContext(), "choice: Silent",
Toast.LENGTH_SHORT).show();
}
else if(checkedId == R.id.sound)
{
Toast.makeText(getApplicationContext(), "choice: Sound",
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(),
"choice:
Vibration",Toast.LENGTH_SHORT).show();
}
}
});
sound = (RadioButton)
findViewById(R.id.sound); vibration =
(RadioButton) findViewById(R.id.vibrate);silent
= (RadioButton) findViewById(R.id.silent);
textView = (TextView)
findViewById(R.id.textView1);button =
(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
int selectedId = radioGroup.getCheckedRadioButtonId();
45
46
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
textView.setText("You chose 'Sound' option");
}
46
47
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
else if(selectedId == vibration.getId())
{
textView.setText("You chose 'Vibration' option");
}
else
{
textView.setText("You chose 'Silent' option");
}
}
});
}
}
MainActivity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<RadioGroup
android:id="@+id/myRadioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginLeft="27dp"
android:layout_marginTop="28dp" >
<RadioButton
android:id="@+id/sound"
android:layout_width="wrap_content"
47
48
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
android:layout_height="wrap_content"
android:checked="true"
android:text="Sound" />
<RadioButton
android:id="@+id/vibrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vibration" />
<RadioButton
android:id="@+id/silent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Silent" />
</RadioGroup>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Choose one of the following modes"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/myRadioGroup"
android:layout_below="@+id/myRadioGroup"
android:layout_marginLeft="42dp"
android:layout_marginTop="53dp"
android:text="choose" />
</RelativeLayout>
48
49
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
OUTPUT:
49
50
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes
50
51
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO: 9
51
52
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Toast.makeText(getApplicationContext(),"Item 1 Selected",Toast.LENGTH_LONG).show();
return true;
case R.id.item2:
Toast.makeText(getApplicationContext(),"Item 2 Selected",Toast.LENGTH_LONG).show();
return true; case
R.id.item3:
Toast.makeText(getApplicationContext(),"Item 3 Selected",Toast.LENGTH_LONG).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
MainActivity.xml
<RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
SecondActivity.xml
<menu xmlns:androclass="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/item1"android:title="Item
1"/>
<item android:id="@+id/item2"android:title="Item
2"/>
<item android:id="@+id/item3"android:title="Item 3"/></menu>
52
53
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
OUTPUT:
53
54
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes:
54
55
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
EXPERIMENT NO : 10
Create a user registration application that stores the user details in a database table.
AIM: To Create a user registration application that stores the user details in a database table.
DbHandler.java
package com.tutlane.sqliteexample;
import android.content.ContentValues;
import android.content.Context; import
android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by tutlane on 06-01-2018.
*/
56
57
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
+ KEY_LOC + " TEXT,"
+ KEY_DESG + "
TEXT"+ ")";
db.execSQL(CREATE_TA
BLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
// Drop older table if exist
db.execSQL("DROP TABLE IF EXISTS " + TABLE_Users);
// Create tables again
onCreate(db);
}
// **** CRUD (Create, Read, Update, Delete) Operations ***** //
57
58
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
ArrayList<>();
String query = "SELECT name, location, designation FROM "+
58
59
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
TABLE_Users;Cursor cursor =
db.rawQuery(query,null); while (cursor.moveToNext()){
HashMap<String,String> user = new
HashMap<>();
user.put("name",cursor.getString(cursor.getColumnIndex(KEY_NAME)));
user.put("designation",cursor.getString(cursor.getColumnIndex(KEY_DESG)));
user.put("location",cursor.getString(cursor.getColumnIndex(KEY_LOC))); userList.add(user);
}
return userList;
}
// Get User Details based on userid
public ArrayList<HashMap<String, String>> GetUserByUserId(int userid)
{SQLiteDatabase db = this.getWritableDatabase();
ArrayList<HashMap<String, String>> userList = new ArrayList<>();
String query = "SELECT name, location, designation FROM "+ TABLE_Users;
Cursor cursor = db.query(TABLE_Users, new String[]{KEY_NAME, KEY_LOC, KEY_DESG},
KEY_ID+"=?",new String[]{String.valueOf(userid)},null, null, null, null);
if (cursor.moveToNext()){
HashMap<String,String> user = new HashMap<>();
user.put("name",cursor.getString(cursor.getColumnIndex(KEY_NAME)));
user.put("designation",cursor.getString(cursor.getColumnIndex(KEY_DESG)));
user.put("location",cursor.getString(cursor.getColumnIndex(KEY_LOC)));
userList.add(user);
}
return userList;
}
// Delete User Details
public void DeleteUser(int userid){
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_Users, KEY_ID+" = ?",new
String[]{String.valueOf(userid)});db.close();
}
// Update User Details
59
60
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
public int UpdateUserDetails(String location, String designation, int
id){SQLiteDatabase db = this.getWritableDatabase();
ContentValues cVals = new
ContentValues();cVals.put(KEY_LOC,
location); cVals.put(KEY_DESG,
designation);
int count = db.update(TABLE_Users, cVals, KEY_ID+" = ?",new String[]
{String.valueOf(id)});
return count;
}
If you observe above code, we implemented all SQLite Database related activities to perform
CRUDoperations in android application.
Now open activity_main.xml file from \res\layout folder path and write the code like as shown below.
activity_main.xml
60
61
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
<TextView
61
62
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
android:id="@+id/secTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location"
android:layout_marginLeft="100dp" /
>
<EditText
android:id="@+id/txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp" android:ems="10"
/>
<TextView
android:id="@+id/thirdTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Designation"
android:layout_marginLeft="100dp" /
>
<EditText
android:id="@+id/txtDesignation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:ems="10" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Save" />
</LinearLayout>
Now we will create another layout resource file details.xml in \res\layout path to show the details in
62
63
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
custom listview from SQLite Database for that right click on your layout folder à Go to New à
select LayoutResource File and give name as details.xml.
Once we create a new layout resource file details.xml, open it and write the code like as shown below
63
64
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
details.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/user_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp" />
<Button
android:id="@+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Back" />
</LinearLayout>
Create an another layout file (list_row.xml) in /res/layout folder to show the data in listview, for that right
click on layout folder àadd new Layout resource file à Give name as list_row.xml and write the code like as
shown below.
list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
64
65
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="17dp" />
<TextView
android:id="@+id/designation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_marginTop="7dp"
android:textColor="#343434"
android:textSize="14dp" />
<TextView
android:id="@+id/location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/designation"
android:layout_alignBottom="@+id/designation"
android:layout_alignParentRight="true"
android:textColor="#343434"
android:textSize="14dp" />
</RelativeLayout>
65
66
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
public class MainActivity extends AppCompatActivity
{EditText name, loc, desig;
66
67
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Button saveBtn;
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name =
(EditText)findViewById(R.id.txtName);loc =
(EditText)findViewById(R.id.txtLocation);
desig = (EditText)findViewById(R.id.txtDesignation);
saveBtn = (Button)findViewById(R.id.btnSave);
saveBtn.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
String username = name.getText().toString()+"\
n"; String location = loc.getText().toString();
String designation = desig.getText().toString();
DbHandler dbHandler = new
DbHandler(MainActivity.this);
dbHandler.insertUserDetails(username,location,designation);
intent = new
Intent(MainActivity.this,DetailsActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Details Inserted Successfully",Toast.LENGTH_SHORT).show();
}
});
}
}
67
68
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
OUTPUT:
68
69
AAR MAHAVEER ENGINEERING COLLEGE(8P)
(Approved by AICTE, Affiliated to JNTU ,Hyderabad)
Vysapuri,Bandlaguda,Post:Keshavagiri,Hyderabad-500005
Record Notes:
69