GOVERNMENT ENGINEERING COLLEGE BHARATPUR
(Department of Artificial Intelligence and Data Science)
MOBILE APPLICATION DEVELOPMENT
LABORATORY MANUAL
Subject Code: 6AID4-24
Academic Year: 2025-26
Submitted To: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Submitted By: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Roll No: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Branch: AI & DS
MAD Practical File 6AID4-24
Index of Experiments
[Link]. Experiment Name Date Page No.
1 Create a basic ”Hello World” Android Application …… …
2 Design a Login Screen with Toast message validation …… …
3 Build a simple Calculator using GridLayout …… …
4 Navigate between Activities using Explicit Intents …… …
5 Display a collection of data using ListView …… …
1
MAD Practical File 6AID4-24
1 Experiment 1
Aim: Create a basic ”Hello World” Android Application and understand the project structure.
Java Code ([Link])
1 package com. example . helloworld ;
2
3 import androidx . appcompat .app. AppCompatActivity ;
4 import android .os. Bundle ;
5
6 public class MainActivity extends AppCompatActivity {
7 @Override
8 protected void onCreate ( Bundle savedInstanceState ) {
9 super . onCreate ( savedInstanceState );
10 setContentView (R. layout . activity_main );
11 }
12 }
XML Layout (activity_main.xml)
1 <?xml version ="1.0" encoding ="utf -8"?>
2 <RelativeLayout xmlns:android =" http: // schemas . android .com/apk/res/ android "
3 android:layout_width =" match_parent "
4 android:layout_height =" match_parent ">
5
6 <TextView
7 android:layout_width =" wrap_content "
8 android:layout_height =" wrap_content "
9 android:text =" Hello World !"
10 android:textSize ="24sp"
11 android:layout_centerInParent ="true" />
12
13 </ RelativeLayout >
Output
[App launches displaying "Hello World!" centered on the screen]
2
MAD Practical File 6AID4-24
2 Experiment 2
Aim: Design a Login Screen taking username and password as input, and display a Toast mes-
sage upon clicking the submit button.
Java Code ([Link])
1 package com. example . loginapp ;
2
3 import androidx . appcompat .app. AppCompatActivity ;
4 import android .os. Bundle ;
5 import android .[Link];
6 import android . widget . Button ;
7 import android . widget . EditText ;
8 import android . widget .Toast;
9
10 public class MainActivity extends AppCompatActivity {
11 EditText username , password ;
12 Button loginBtn ;
13
14 @Override
15 protected void onCreate ( Bundle savedInstanceState ) {
16 super . onCreate ( savedInstanceState );
17 setContentView (R. layout . activity_main );
18
19 username = findViewById ([Link]. username );
20 password = findViewById ([Link]. password );
21 loginBtn = findViewById ([Link]. loginBtn );
22
23 loginBtn . setOnClickListener (new View. OnClickListener () {
24 @Override
25 public void onClick (View v) {
26 if( username . getText (). toString (). equals ("admin ") &&
27 password . getText (). toString (). equals ("1234")) {
28 Toast. makeText ( MainActivity .this , " Login Successful ", Toast.
LENGTH_SHORT ).show ();
29 } else {
30 Toast. makeText ( MainActivity .this , " Login Failed ", Toast.
LENGTH_SHORT ).show ();
31 }
32 }
33 });
34 }
35 }
Output
[User enters "admin" and "1234", clicks Login. Toast displays: "Login Successful"]
3
MAD Practical File 6AID4-24
3 Experiment 3
Aim: Build a simple Arithmetic Calculator layout using GridLayout.
XML Layout (activity_main.xml)
1 <?xml version ="1.0" encoding ="utf -8"?>
2 <LinearLayout xmlns:android ="http: // schemas . android .com/apk/res/ android "
3 android:layout_width =" match_parent "
4 android:layout_height =" match_parent "
5 android:orientation =" vertical "
6 android:padding ="16dp">
7
8 <EditText
9 android:id ="@+id/ resultDisplay "
10 android:layout_width =" match_parent "
11 android:layout_height =" wrap_content "
12 android:textSize ="32sp"
13 android:gravity ="end"
14 android:layout_marginBottom ="24dp"/>
15
16 <GridLayout
17 android:layout_width =" match_parent "
18 android:layout_height =" wrap_content "
19 android:columnCount ="4"
20 android:rowCount ="4">
21
22 <Button android:text ="7" />
23 <Button android:text ="8" />
24 <Button android:text ="9" />
25 <Button android:text ="/" />
26
27 <Button android:text ="4" />
28 <Button android:text ="5" />
29 <Button android:text ="6" />
30 <Button android:text ="*" />
31
32 <Button android:text ="1" />
33 <Button android:text ="2" />
34 <Button android:text ="3" />
35 <Button android:text ="-" />
36
37 <Button android:text ="C" />
38 <Button android:text ="0" />
39 <Button android:text ="=" />
40 <Button android:text ="+" />
41
42 </ GridLayout >
43 </ LinearLayout >
Output
[UI renders a classic calculator keypad layout with a text display at the top]
4
MAD Practical File 6AID4-24
4 Experiment 4
Aim: Navigate between two Activities and pass data using Explicit Intents.
Java Code ([Link])
1 package com. example . intentapp ;
2
3 import androidx . appcompat .app. AppCompatActivity ;
4 import android . content . Intent ;
5 import android .os. Bundle ;
6 import android .[Link];
7 import android . widget . Button ;
8
9 public class MainActivity extends AppCompatActivity {
10 Button nextBtn ;
11
12 @Override
13 protected void onCreate ( Bundle savedInstanceState ) {
14 super . onCreate ( savedInstanceState );
15 setContentView (R. layout . activity_main );
16
17 nextBtn = findViewById ([Link]. nextBtn );
18 nextBtn . setOnClickListener (new View. OnClickListener () {
19 @Override
20 public void onClick (View v) {
21 Intent intent = new Intent ( MainActivity .this , SecondActivity .
class );
22 intent . putExtra (" MESSAGE ", " Hello from First Activity !");
23 startActivity ( intent );
24 }
25 });
26 }
27 }
Java Code ([Link])
1 package com. example . intentapp ;
2
3 import androidx . appcompat .app. AppCompatActivity ;
4 import android .os. Bundle ;
5 import android . widget . TextView ;
6
7 public class SecondActivity extends AppCompatActivity {
8 TextView displayTxt ;
9
10 @Override
11 protected void onCreate ( Bundle savedInstanceState ) {
12 super . onCreate ( savedInstanceState );
13 setContentView (R. layout . activity_second );
14
15 displayTxt = findViewById ([Link]. displayTxt );
16 String msg = getIntent (). getStringExtra (" MESSAGE ");
17 displayTxt . setText (msg);
18 }
5
MAD Practical File 6AID4-24
19 }
Output
[User clicks "Next" on Screen 1. Screen 2 opens displaying: "Hello from First Activity!"]
6
MAD Practical File 6AID4-24
5 Experiment 5
Aim: Display a static collection of data (e.g., list of subjects) using a ListView and an ArrayAdapter.
Java Code ([Link])
1 package com. example . listviewapp ;
2
3 import androidx . appcompat .app. AppCompatActivity ;
4 import android .os. Bundle ;
5 import android .[Link];
6 import android . widget . AdapterView ;
7 import android . widget . ArrayAdapter ;
8 import android . widget . ListView ;
9 import android . widget .Toast;
10
11 public class MainActivity extends AppCompatActivity {
12 ListView subjectList ;
13 String [] subjects = {" Machine Learning ", " Mobile App Dev", " Cloud Computing "
, " Cyber Security "};
14
15 @Override
16 protected void onCreate ( Bundle savedInstanceState ) {
17 super . onCreate ( savedInstanceState );
18 setContentView (R. layout . activity_main );
19
20 subjectList = findViewById ([Link]. subjectList );
21 ArrayAdapter <String > adapter = new ArrayAdapter <>(this , android .R. layout
. simple_list_item_1 , subjects );
22 subjectList . setAdapter ( adapter );
23
24 subjectList . setOnItemClickListener (new AdapterView . OnItemClickListener ()
{
25 @Override
26 public void onItemClick ( AdapterView <?> parent , View view , int
position , long id) {
27 Toast. makeText ( MainActivity .this , " Selected : " + subjects [
position ], Toast. LENGTH_SHORT ).show ();
28 }
29 });
30 }
31 }
Output
[App displays a vertical list of subjects. Tapping "Machine Learning" shows a Toast: "Selected: