Android Lab Manual
Android Lab Manual
Main_Activity.java
1 | Page
NEP: - Android Application Development Lab Manual
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
Screenshot:
2 | Page
NEP: - Android Application Development Lab Manual
xmlns:android="[Link]
xmlns:tools="[Link]
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/[Link]"
tools:targetApi="31">
<activity
android:name=".NextActivity"
android:exported="false"
android:screenOrientation="landscape"/>
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]"/>
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
3 | Page
NEP: - Android Application Development Lab Manual
4 | Page
NEP: - Android Application Development Lab Manual
android:textSize="22dp"
android:text="This activity is portrait orientation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</[Link]>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
public void onClick(View v) {
Intent intent = new Intent([Link],[Link]);
startActivity(intent);
}
}
activity_next.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
5 | Page
NEP: - Android Application Development Lab Manual
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NextActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8sp"
android:layout_marginStart="8sp"
android:layout_marginTop="180sp"
android:text="This is landscape orientation"
android:textSize="22sp"
tools:ignore="MissingConstraints" />
</[Link]>
[Link]
package [Link];
import [Link];
import [Link];
public class NextActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_next);
6 | Page
NEP: - Android Application Development Lab Manual
}
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
<application
android:allowBackup="true"
android:theme="@style/[Link]"
android:label="LoginDemo">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]"/>
<category android:name="[Link]"/>
</intent-filter>
</activity>
7 | Page
NEP: - Android Application Development Lab Manual
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp">
<EditText
android:id="@+id/etUsername"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Username"
android:inputType="text"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<EditText
android:id="@+id/etPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintTop_toBottomOf="@id/etUsername"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"/>
<Button
android:id="@+id/btnLogin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Login"
app:layout_constraintTop_toBottomOf="@id/etPassword"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="24dp"/>
</[Link]>
8 | Page
NEP: - Android Application Development Lab Manual
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
findViewById([Link]).setOnClickListener(v ->
[Link](this, "Login clicked",
Toast.LENGTH_SHORT).show()
);
}
}
9 | Page
NEP: - Android Application Development Lab Manual
Experiment 4:
Create an application to implement new activity using explicit
intent, implicit intent and content provider.
activity_main.xml
<LinearLayout
xmlns:android="[Link]
android:orientation="vertical"
android:padding="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnExplicit"
android:text="Explicit Intent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
findViewById([Link]).setOnClickListener(v ->
startActivity(new Intent(this, [Link]))
);
}
}
10 | Page
NEP: - Android Application Development Lab Manual
activity_second.xml
<LinearLayout
xmlns:android="[Link]
android:padding="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnImplicit"
android:text="Open Google"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_second);
findViewById([Link]).setOnClickListener(v ->
startActivity(new Intent(
Intent.ACTION_VIEW,
[Link]("[Link]
))
);
}
}
11 | Page
NEP: - Android Application Development Lab Manual
[Link]
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
12 | Page
NEP: - Android Application Development Lab Manual
activity_ [Link]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#6200EE">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@mipmap/ic_launcher"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Splash Demo"
13 | Page
NEP: - Android Application Development Lab Manual
android:textColor="@android:color/white"
android:textSize="24sp"
android:layout_marginTop="16dp"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_splash);
new Handler().postDelayed(() -> {
Intent intent = new Intent([Link],
[Link]);
startActivity(intent);
finish();
}, 3000); // 3 seconds
}
}
Create a file called inside values [Link]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- App theme -->
<style name="[Link]"
parent="[Link]">
<item
name="android:statusBarColor">@android:color/black</item>
14 | Page
NEP: - Android Application Development Lab Manual
<item
name="android:navigationBarColor">@android:color/black</item>
</style>
</resources>
15 | Page
NEP: - Android Application Development Lab Manual
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
16 | Page
NEP: - Android Application Development Lab Manual
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
// 1. Initialize Views
Button btnSubmit = findViewById([Link]);
EditText etInput = findViewById([Link]);
Switch switchEnable = findViewById([Link]);
CheckBox checkBoxAgree =
findViewById([Link]);
RadioGroup radioGroup = findViewById([Link]);
Spinner spinner = findViewById([Link]);
SeekBar seekBar = findViewById([Link]);
// 2. Setup Spinner Data
List<String> categories = new ArrayList<>();
[Link]("Select Category");
[Link]("Work");
17 | Page
NEP: - Android Application Development Lab Manual
[Link]("Personal");
[Link]("Other");
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
[Link].simple_spinner_item,
categories
);
[Link]([Link].simple_spin
ner_dropdown_item);
[Link](adapter);
// 3. Setup Button Click Listener
[Link](new [Link]() {
@Override
public void onClick(View v) {
String name = [Link]().toString();
boolean isAgreed = [Link]();
boolean isEnabled = [Link]();
// Get selected Radio Button
int selectedId =
[Link]();
RadioButton selectedRadio = findViewById(selectedId);
String radioText = (selectedRadio != null) ?
[Link]().toString() : "None";
String message = "Name: " + name + "\nAgreed: " +
isAgreed +
"\nEnabled: " + isEnabled + "\nOption: " +
radioText;
18 | Page
NEP: - Android Application Development Lab Manual
[Link]([Link], message,
Toast.LENGTH_LONG).show();
}
});
// 4. Setup SeekBar Listener
[Link](new
[Link]() {
@Override
public void onProgressChanged(SeekBar seekBar, int
progress, boolean fromUser) {
// Handle progress change
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
19 | Page
NEP: - Android Application Development Lab Manual
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Standard TextView"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginBottom="10dp"/>
<[Link]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your name">
<[Link]
android:id="@+id/etInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</[Link]>
<Button
android:id="@+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Submit Button"
android:layout_marginTop="10dp"/>
20 | Page
NEP: - Android Application Development Lab Manual
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<Switch
android:id="@+id/switchEnable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable Feature"
android:layout_marginEnd="20dp"/>
<ToggleButton
android:id="@+id/toggleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toggle"/>
</LinearLayout>
<CheckBox
android:id="@+id/checkBoxAgree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I agree to Terms"/>
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
21 | Page
NEP: - Android Application Development Lab Manual
<RadioButton
android:id="@+id/radioOption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option A"/>
<RadioButton
android:id="@+id/radioOption2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option B"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Image View:"
android:layout_marginTop="15dp"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@android:drawable/ic_menu_camera"
android:background="#E0E0E0"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Volume Control:"
22 | Page
NEP: - Android Application Development Lab Manual
android:layout_marginTop="15dp"/>
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"/>
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading..."
android:layout_marginTop="15dp"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="75"
android:max="100"/>
</LinearLayout>
</ScrollView>
23 | Page
NEP: - Android Application Development Lab Manual
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:label="Menu App"
24 | Page
NEP: - Android Application Development Lab Manual
android:theme="@style/[Link]">
<activity
android:name="[Link]"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_menu);
25 | Page
NEP: - Android Application Development Lab Manual
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Creates the menu from XML
getMenuInflater().inflate([Link].options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Simplified click handling
[Link](this, [Link]() + " selected",
Toast.LENGTH_SHORT).show();
return true;
}
}
Rename the file as activity_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
android:id="@+id/mainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu Application"
android:textSize="22sp"
26 | Page
NEP: - Android Application Development Lab Manual
android:textStyle="bold"
android:layout_centerInParent="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/mainTitle"
android:layout_centerHorizontal="true"
android:text="Check the top right for Options"
android:layout_marginTop="8dp"/>
</RelativeLayout>
Create a path in res folder create a sub directory called menu
and place xml file
options_menu.xml res/menu/options_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="[Link]
xmlns:app="[Link]
<item
android:id="@+id/action_add"
android:title="Add"
android:icon="@android:drawable/ic_menu_add"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_edit"
android:title="Edit"
android:icon="@android:drawable/ic_menu_edit"
app:showAsAction="ifRoom" />
<item
27 | Page
NEP: - Android Application Development Lab Manual
android:id="@+id/action_settings"
android:title="Settings"
app:showAsAction="never" />
<item
android:id="@+id/action_about"
android:title="About Us"
app:showAsAction="never" />
</menu>
28 | Page
NEP: - Android Application Development Lab Manual
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Local Data App"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
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:orientation="vertical"
android:padding="24dp"
29 | Page
NEP: - Android Application Development Lab Manual
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Local Data Manager"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginBottom="30dp"/>
<EditText
android:id="@+id/etData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type data to write..."
android:minHeight="48dp"
android:background="@android:drawable/editbox_background"/>
<Button
android:id="@+id/btnSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save & Update"
android:layout_marginTop="10dp"
android:backgroundTint="#4CAF50"
android:textColor="#FFFFFF"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Read from Storage:"
30 | Page
NEP: - Android Application Development Lab Manual
android:layout_marginTop="40dp"
android:textStyle="italic"/>
<TextView
android:id="@+id/tvDisplay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No data yet"
android:textSize="18sp"
android:padding="10dp"
android:gravity="center"
android:background="#F0F0F0"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear Storage"
style="@style/[Link]"
android:textColor="#F44336"
android:layout_marginTop="20dp"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
31 | Page
NEP: - Android Application Development Lab Manual
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);]
setContentView([Link].activity_main);
EditText et = findViewById([Link]);
TextView tv = findViewById([Link]);
SharedPreferences sp = getSharedPreferences("LocalStore",
MODE_PRIVATE);
// 1. READ: Load data immediately on startup
String savedValue = [Link]("note", "Empty");
[Link](savedValue);
// 2. WRITE: Save when button is clicked
findViewById([Link]).setOnClickListener(v -> { String
input = [Link]().toString();
[Link]().putString("note", input).apply(); // Immediately READ
back to the display to show it worked
[Link](input);
[Link](this, "Saved!", Toast.LENGTH_SHORT).show();
});
32 | Page
NEP: - Android Application Development Lab Manual
33 | Page
NEP: - Android Application Development Lab Manual
android:theme="@style/[Link]">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
</application></manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
34 | Page
NEP: - Android Application Development Lab Manual
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SQLite Database Storage"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginBottom="24dp"/>
<EditText
android:id="@+id/etData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter text for Database"
android:inputType="text"
android:minHeight="48dp" />
<Button
android:id="@+id/btnSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save to SQLite"
35 | Page
NEP: - Android Application Development Lab Manual
android:layout_marginTop="12dp"
android:backgroundTint="#2196F3"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DDDDDD"
android:layout_marginVertical="24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Latest Record in DB:"
android:textStyle="italic" />
<TextView
android:id="@+id/tvDisplay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No data found"
android:textSize="18sp"
android:padding="12dp"
android:gravity="center"
android:background="#F5F5F5"
android:layout_marginTop="8dp"/>
<Button
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete All Data"
android:layout_marginTop="30dp"
36 | Page
NEP: - Android Application Development Lab Manual
style="@style/[Link]"
android:textColor="#D32F2F"/>
</LinearLayout>
</ScrollView>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
EditText et;
TextView tv;
DBHelper dbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
et = findViewById([Link]);
37 | Page
NEP: - Android Application Development Lab Manual
tv = findViewById([Link]);
dbHelper = new DBHelper(this);
// 1. READ: Load the last entry from DB on start
readData();
// 2. WRITE: Save to DB on click
findViewById([Link]).setOnClickListener(v -> {
SQLiteDatabase db = [Link]();
ContentValues cv = new ContentValues();
[Link]("content", [Link]().toString());
// Insert data into table "notes"
[Link]("notes", null, cv);
readData(); // Refresh display
[Link](this, "Saved to SQLite!",
Toast.LENGTH_SHORT).show();
});
// 3. DELETE: Clear DB
findViewById([Link]).setOnClickListener(v -> {
[Link]().execSQL("DELETE FROM
notes");
readData();
});
}
void readData() {
SQLiteDatabase db = [Link]();
Cursor c = [Link]("SELECT content FROM notes ORDER
BY id DESC LIMIT 1", null);
if ([Link]()) {
38 | Page
NEP: - Android Application Development Lab Manual
39 | Page
NEP: - Android Application Development Lab Manual
android:theme="@style/[Link]">
<activity
android:name="[Link]"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
<receiver android:name=".MySMSReceiver"
40 | Page
NEP: - Android Application Development Lab Manual
android:exported="true"
android:permission="[Link].BROADCAST_SMS">
<intent-filter>
<action
android:name="[Link].SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
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:orientation="vertical"
android:padding="20dp">
<EditText
android:id="@+id/etPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Phone Number"
android:inputType="phone" />
<EditText
android:id="@+id/etMessage"
android:layout_width="match_parent"
41 | Page
NEP: - Android Application Development Lab Manual
android:layout_height="wrap_content"
android:hint="Enter Message"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btnSend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send SMS"
android:layout_marginTop="20dp" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
42 | Page
NEP: - Android Application Development Lab Manual
setContentView([Link].activity_main);
EditText etPhone = findViewById([Link]);
EditText etMsg = findViewById([Link]);
findViewById([Link]).setOnClickListener(v -> {
// Check for permission at runtime
if ([Link](this,
[Link].SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
[Link](this, new
String[]{[Link].SEND_SMS}, 1);
} else {
sendSMS([Link]().toString(),
[Link]().toString());
}
});
}
private void sendSMS(String phone, String message) {
try {
SmsManager smsManager = [Link]();
[Link](phone, null, message, null,
null);
[Link](this, "Message Sent!",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
[Link](this, "Failed to send SMS",
Toast.LENGTH_SHORT).show();
}
}
}
43 | Page
NEP: - Android Application Development Lab Manual
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MySMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if
([Link].SMS_RECEIVED_ACTION.equals([Link]
on())) {
for (SmsMessage smsMessage :
[Link](intent)) {
String messageBody = [Link]();
[Link](context, "New SMS: " + messageBody,
Toast.LENGTH_LONG).show();
}
}
}
}
44 | Page
NEP: - Android Application Development Lab Manual
android:theme="@style/[Link]">
<activity
45 | Page
NEP: - Android Application Development Lab Manual
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
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:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
46 | Page
NEP: - Android Application Development Lab Manual
android:text="Send Email"
android:textSize="24sp"
android:textStyle="bold"
android:layout_gravity="center"
android:layout_marginBottom="20dp"/>
<EditText
android:id="@+id/etTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="To: (example@[Link])"
android:inputType="textEmailAddress"
android:minHeight="48dp" />
<EditText
android:id="@+id/etSubject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject"
android:layout_marginTop="10dp"
android:inputType="text"
android:minHeight="48dp" />
<EditText
android:id="@+id/etMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Message Body"
android:layout_marginTop="10dp"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="6"
47 | Page
NEP: - Android Application Development Lab Manual
android:minHeight="48dp" />
<Button
android:id="@+id/btnSend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Open Email Client"
android:layout_marginTop="20dp"
android:backgroundTint="#1A73E8"
android:textColor="#FFFFFF" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
48 | Page
NEP: - Android Application Development Lab Manual
EditText etTo = findViewById([Link]);
EditText etSubject = findViewById([Link]);
// This must match the @+id/etMsg you set in the XML
EditText etMessage = findViewById([Link]);
findViewById([Link]).setOnClickListener(v -> {
String to = [Link]().toString();
String subject = [Link]().toString();
String message = [Link]().toString();
Intent intent = new Intent(Intent.ACTION_SEND);
// Set type to message/rfc822 to ensure only email apps
respond
[Link]([Link]("[Link]
[Link]("message/rfc822");
[Link](Intent.EXTRA_EMAIL, new String[]{to});
[Link](Intent.EXTRA_SUBJECT, subject);
[Link](Intent.EXTRA_TEXT, message);
try {
// Use a chooser to allow user to pick their favorite email
app
startActivity([Link](intent, "Choose an Email
Client"));
} catch (Exception e) {
[Link](this, "No email apps found",
Toast.LENGTH_SHORT).show();
}
});
49 | Page
NEP: - Android Application Development Lab Manual
}
}
[Link]
50 | Page
NEP: - Android Application Development Lab Manual
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/[Link]"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="[Link]" />
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:tools="[Link]
android:id="@+id/map"
51 | Page
NEP: - Android Application Development Lab Manual
android:name="[Link]
nt"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" />
[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];
import [Link];
public class MainActivity extends FragmentActivity implements
OnMapReadyCallback {
52 | Page
NEP: - Android Application Development Lab Manual
private GoogleMap mMap;
private static final int LOCATION_PERMISSION_REQUEST_CODE =
101;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
// 1. Check and Request Permissions immediately
if ([Link](this,
[Link].ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
[Link](this,
new
String[]{[Link].ACCESS_FINE_LOCATION,
[Link].ACCESS_COARSE_LOCATION},
LOCATION_PERMISSION_REQUEST_CODE);
}
// 2. Initialize the Map Fragment
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById([Link]);
if (mapFragment != null) {
[Link](this);
}
}
@Override
53 | Page
NEP: - Android Application Development Lab Manual
[Link]([Link](bengaluru
, 12.0f));
// Optional: Enable zoom controls
[Link]().setZoomControlsEnabled(true);
}
}
54 | Page
NEP: - Android Application Development Lab Manual
activity_main.xml
55 | Page
NEP: - Android Application Development Lab Manual
android:layout_marginBottom="30dp"/>
<EditText
android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:inputType="text" />
<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:layout_marginTop="20dp" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
56 | Page
NEP: - Android Application Development Lab Manual
57 | Page
NEP: - Android Application Development Lab Manual
58 | Page
NEP: - Android Application Development Lab Manual
</[Link]>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
// Generated automatically
public class MainActivity extends AppCompatActivity {
// Declare the binding variable
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
59 | Page
NEP: - Android Application Development Lab Manual
60 | Page