0% found this document useful (0 votes)
27 views16 pages

Unit Vi

The document outlines key aspects of Android development, including the Android Security Model, methods to obtain location data, and the significance of content providers. It also provides sample code for various applications, such as displaying sensors, sending emails and SMS, and integrating Google Maps with geocoding functionalities. Additionally, it discusses the necessary permissions and UI elements required for these applications.

Uploaded by

rashinirale865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views16 pages

Unit Vi

The document outlines key aspects of Android development, including the Android Security Model, methods to obtain location data, and the significance of content providers. It also provides sample code for various applications, such as displaying sensors, sending emails and SMS, and integrating Google Maps with geocoding functionalities. Additionally, it discusses the necessary permissions and UI elements required for these applications.

Uploaded by

rashinirale865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

UNIT VI

1. Elaborate Android Security Model.

The Android Security Model keeps your data and device safe using different methods.
The five main parts are:
A. Design Review
Experts check Android’s design early to find and fix possible security problems.
B. Penetration Testing and Code Review
Google tests the system and reviews the code to catch and fix security bugs
before updates are released.
C. Open Source and Community Review
Android is open-source, so anyone in the developer community can check the
code and report issues.
D. Incident Response
Google has a team that quickly fixes security issues and sends updates to users
and phone companies.
E. Monthly Security Updates
Android phones get security updates every month to protect against new
threats.

2. Name any four methods to get location data in android.

 GPS Provider – Uses satellites to get the most accurate location.


 Network Provider – Uses mobile networks and Wi-Fi for faster, less accurate
location.
 Fused Location Provider – A Google API that combines GPS, Wi-Fi, and cell data
for better accuracy and battery saving.
 Passive Provider – Gets location updates when other apps or services request
location, saving battery.

3. Explain significance of content provider


A Content Provider in Android is used to share data between different apps
securely.
Significance:
 Data Sharing – It allows apps to access data from other apps (like contacts,
media, etc.).
 Secure Access – Only authorized apps can read/write data using permissions.
 Standard Interface – Uses URIs to perform operations like insert, update,
delete, and query.
 Structured Storage – Manages data in a structured way using databases or
files.

4. Write a program to display the list of sensors supported by device.

✅ XML Layout (res/layout/activity_main.xml)

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent">
<TextView

android:id="@+id/sensorListText"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="16dp"

android:textSize="16sp" />

</ScrollView>

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
import java.util.List;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

TextView textView = new TextView(this);


SensorManager sensorManager = (SensorManager)
getSystemService(SENSOR_SERVICE);
List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);

StringBuilder sensors = new StringBuilder("Sensors:\n");


for (Sensor sensor : sensorList) {
sensors.append(sensor.getName()).append("\n");
}

textView.setText(sensors.toString());
setContentView(textView);
}
}

5. Write a program to send e-mail.

✅ XML Layout (res/layout/activity_main.xml)

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


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">

<Button
android:id="@+id/sendEmailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send Email" />
</LinearLayout>

✅ Java Code (MainActivity.java)


import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button sendEmail = findViewById(R.id.sendEmailButton);


sendEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:")); // Only email apps should handle this
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Test Email");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hello, this is a test email.");

if (emailIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(emailIntent, "Send Email"));
}
}
});
}
}
6. Write a program to show users current location.

✅ 1. Add Permissions in AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

✅ 2. XML Layout (res/layout/activity_main.xml)

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


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">

<TextView
android:id="@+id/locationText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Fetching location..."
android:textSize="18sp" />
</LinearLayout>

✅ 3. Java Code (MainActivity.java)


import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.widget.TextView;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnSuccessListener;

public class MainActivity extends Activity {

private FusedLocationProviderClient fusedLocationClient;


private TextView locationText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationText = findViewById(R.id.locationText);

fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

// Check permission
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
} else {
showLocation();
}
}

private void showLocation() {


fusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {
String loc = "Latitude: " + location.getLatitude() +
"\nLongitude: " + location.getLongitude();
locationText.setText(loc);
} else {
locationText.setText("Location not available");
}
}
});
}
}

7. Develop a program to send an SMS.

✅ 1. Permissions in AndroidManifest.xml

<uses-permission android:name="android.permission.SEND_SMS" />


✅ 2. XML Layout (res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">

<EditText
android:id="@+id/phoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter phone number"
android:inputType="phone" />

<EditText
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter message"
android:inputType="textMultiLine" />

<Button
android:id="@+id/sendBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send SMS" />
</LinearLayout>
✅ 3. Java Code (MainActivity.java)
import android.Manifest;
import android.app.Activity;
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;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class MainActivity extends Activity {

EditText phoneNumber, message;


Button sendBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

phoneNumber = findViewById(R.id.phoneNumber);
message = findViewById(R.id.message);
sendBtn = findViewById(R.id.sendBtn);

// Request SMS permission


if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS}, 1);
}

sendBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String number = phoneNumber.getText().toString();
String msg = message.getText().toString();

try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, msg, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "SMS Failed",
Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
});
}
}
8. Explain two methods of Google Map.
addMarker()
 This method is used to add a marker (pin) on the map at a specific latitude and
longitude.
 Example:
googleMap.addMarker(new MarkerOptions().position(new LatLng(19.0760,
72.8777)).title("Mumbai"));
moveCamera()
 It is used to move the camera view to a specific location on the map.
 Example:googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new
LatLng(19.0760, 72.8777), 12));

9. Define Geocoding and Reverse Geocoding.

A. Geocoding:
It is the process of converting an address or location name into geographic
coordinates (latitude & longitude).
1. Example: "Taj Mahal, Agra" → 27.1751, 78.0421
B. Reverse Geocoding:
It is the process of converting geographic coordinates into a readable address.

Example: 28.6139, 77.2090 → "Rajpath, India Gate, New Delhi"

10. Develop an application to display a Google Map. (Write JAVA and Manifest file)

✅ AndroidManifest.xml (with required permissions and API key)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.simplemap">

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application

android:label="Simple Map"

android:theme="@style/Theme.AppCompat.Light.NoActionBar">

<meta-data

android:name="com.google.android.geo.API_KEY"

android:value="YOUR_API_KEY_HERE" />

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

</application>

</manifest>

✅ Layout File (res/layout/activity_main.xml)

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
✅ Java Code (MainActivity.java)
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;

public class MainActivity extends FragmentActivity implements OnMapReadyCallback {


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

public void onMapReady(GoogleMap googleMap) {


LatLng point = new LatLng(19.0760, 72.8777); // Mumbai
googleMap.addMarker(new MarkerOptions().position(point).title("Mumbai"));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 12));
}
}
11. State and elaborate the syntax of required class and methods for Geocoding.
🔹 Class Used:
Geocoder
This class is used to convert an address into coordinates and coordinates into an
address.
🔹 Constructor:
Geocoder geocoder = new Geocoder(Context context, Locale locale);
 context: The current context (usually this or getApplicationContext()).
 locale: (Optional) Set the desired language or region.

🔹 Main Methods:
1. getFromLocation(double latitude, double longitude, int maxResults)
 🔁 Converts coordinates to address (Reverse Geocoding).
List<Address> addresses = geocoder.getFromLocation(19.0760, 72.8777, 1);
 latitude and longitude: GPS coordinates.
 maxResults: Number of results you want (usually 1).
 returns: List of Address objects.

2. getFromLocationName(String locationName, int maxResults)


 🔁 Converts address to coordinates (Geocoding).
List<Address> addresses = geocoder.getFromLocationName("Taj Mahal", 1);
 locationName: String address or landmark name.
 maxResults: Number of possible results to return.

✅ Example:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(28.6139, 77.2090, 1);
if (!addresses.isEmpty()) {
String address = addresses.get(0).getAddressLine(0);
}

12. Develop and application to send and receive SMS (Design minimal UI as per your choice.
Write XML, java and manifest file)

✅ 1. AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.smsapp">

<uses-permission android:name="android.permission.SEND_SMS" />

<uses-permission android:name="android.permission.RECEIVE_SMS" />

<uses-permission android:name="android.permission.READ_SMS" />

<application

android:label="SMS App"

android:theme="@style/Theme.AppCompat.Light.DarkActionBar">

<!-- SMS Receiver -->

<receiver android:name=".SMSReceiver">

<intent-filter>

<action android:name="android.provider.Telephony.SMS_RECEIVED" />

</intent-filter>
</receiver>

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

</application>

</manifest>

✅ 2. res/layout/activity_main.xml (Minimal UI)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:padding="20dp"

android:layout_width="match_parent" android:layout_height="match_parent">

<EditText

android:id="@+id/phoneNumber"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Phone Number" />

<EditText

android:id="@+id/message"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Enter Message" />

<Button

android:id="@+id/sendBtn"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Send SMS" />

<TextView
android:id="@+id/receivedMsg"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Received Message:"

android:textSize="16sp" />

</LinearLayout>

✅ 3. MainActivity.java

import android.Manifest;

import android.content.pm.PackageManager;

import android.os.Bundle;

import android.telephony.SmsManager;

import android.view.View;

import android.widget.*;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.app.ActivityCompat;

public class MainActivity extends AppCompatActivity {

EditText phoneNumber, message;

Button sendBtn;

public static TextView receivedMsg;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

phoneNumber = findViewById(R.id.phoneNumber);

message = findViewById(R.id.message);

sendBtn = findViewById(R.id.sendBtn);

receivedMsg = findViewById(R.id.receivedMsg);

// Request permissions

ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_SMS,
Manifest.permission.READ_SMS}, 1);

sendBtn.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String number = phoneNumber.getText().toString();

String msg = message.getText().toString();

try {

SmsManager smsManager = SmsManager.getDefault();

smsManager.sendTextMessage(number, null, msg, null, null);

Toast.makeText(getApplicationContext(), "SMS Sent",


Toast.LENGTH_SHORT).show();

} catch (Exception e) {

Toast.makeText(getApplicationContext(), "Sending Failed",


Toast.LENGTH_SHORT).show();

});

13. Define SMS service in android application development.


In Android application development, the SMS service allows an app to send and
receive text messages (SMS) using the phone’s built-in messaging capabilities.
SMS service in Android allows apps to send and receive text messages.
 To send SMS, use SmsManager.
 To receive SMS, use BroadcastReceiver.
 Needs permissions: SEND_SMS, RECEIVE_SMS, READ_SMS.
 Used in OTP, alerts, and chat apps.

14. List different types of sensors used in android.


🔹 Types of Sensors in Android:
1. Motion Sensors
o Accelerometer
o Gyroscope
o Gravity sensor
o Step detector
2. Environmental Sensors
o Light sensor
o Pressure sensor (Barometer)
o Temperature sensor
o Humidity sensor
3. Position Sensors
o Proximity sensor
o Magnetometer (used for compass)
o Orientation sensor

15. Develop an android application to show current location of an user’s car.

✅ 1. Permissions in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cartracker">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-permission android:name="android.permission.INTERNET" />

<application
android:label="Car Location Tracker"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY_HERE" />

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
🔁 Replace YOUR_API_KEY_HERE with your actual Google Maps API key.

✅ 2. Layout File (activity_main.xml)


<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

✅ 3. MainActivity.java
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.location.*;
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;

public class MainActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;


private FusedLocationProviderClient fusedLocationClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
return;
}

mMap.setMyLocationEnabled(true);

fusedLocationClient.getLastLocation().addOnSuccessListener(this, location -> {


if (location != null) {
LatLng carLocation = new LatLng(location.getLatitude(),
location.getLongitude());
mMap.addMarker(new MarkerOptions()
.position(carLocation)
.title("Your Car Location"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(carLocation, 15));
}
});
}

@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1 && grantResults.length > 0 &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
onMapReady(mMap);
}
}
}

16. Explain Geocoding and Reverse Geocoding with suitable example.

🔹 Geocoding

Definition: Geocoding is the process of converting a place name or address into latitude
and longitude coordinates.

Example:
Input: "Gateway of India, Mumbai"
Output: Latitude = 18.921984, Longitude = 72.834654

📌 Used in: Finding the location of landmarks, addresses, or user input on a map.
🔹 Reverse Geocoding

Definition: Reverse Geocoding is the process of converting latitude and longitude into a
human-readable address.

Example:
Input: Latitude = 28.6139, Longitude = 77.2090
Output: "Rajpath Area, Central Secretariat, New Delhi, India"

📌 Used in: Displaying current location address from GPS coordinates.

🔹 Android Code Example:

Geocoder geocoder = new Geocoder(this, Locale.getDefault());


List<Address> addresses = geocoder.getFromLocation(28.6139, 77.2090, 1);
String address = addresses.get(0).getAddressLine(0); // Reverse Geocoding

List<Address> list = geocoder.getFromLocationName("Taj Mahal", 1);


double lat = list.get(0).getLatitude(); // Geocoding
double lon = list.get(0).getLongitude();

17. Describe process of getting the map API Key.


🔹 Steps to Get Google Maps API Key:
1. Go to Google Cloud Console
Website: https://console.cloud.google.com
2. Create a New Project
o Click on "New Project"
o Give your project a name (e.g., CarTrackingApp)
o Click "Create"
3. Enable Maps SDK for Android
o In the project dashboard, go to APIs & Services > Library
o Search for Maps SDK for Android
o Click Enable
4. Generate API Key
o Go to APIs & Services > Credentials
o Click Create Credentials > API key
o Copy the generated key
5. Add API Key to Android App
o Open your app's AndroidManifest.xml
o Add the following inside the <application> tag:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY_HERE" />

18. List and elaborate steps to deploy an Android application on Google play store.

 Create Developer Account – Register at Google Play Console and pay one-time
$25 fee.
 Build Signed APK/AAB – Create a signed app bundle for release.
 Test the App – Make sure the app runs smoothly on devices.
 Create App in Play Console – Add app name, details, and accept policies.
 Upload AAB File – Go to Production > Create Release, upload the AAB.
 Add Store Listing – Fill title, description, screenshots, icon, etc.
 Set Rating and Pricing – Choose content rating and free/paid status.
 Review and Publish – Review all settings and click "Publish".

19. Develop an android application for sending Short Message Service (SMS).

✅ 1. Permission in AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_SMS" />

✅ 2. Layout (activity_main.xml)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:padding="16dp">

<EditText android:id="@+id/phone" android:hint="Phone Number"


android:layout_width="match_parent" android:layout_height="wrap_content" />

<EditText android:id="@+id/message" android:hint="Message"


android:layout_width="match_parent" android:layout_height="wrap_content" />

<Button android:id="@+id/send" android:text="Send SMS"


android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>

✅ 3. Java Code (MainActivity.java)

import android.Manifest;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

public class MainActivity extends AppCompatActivity {


EditText phone, message;
Button send;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
phone = findViewById(R.id.phone);
message = findViewById(R.id.message);
send = findViewById(R.id.send);

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS},


1);

send.setOnClickListener(v -> {
String number = phone.getText().toString();
String msg = message.getText().toString();
SmsManager.getDefault().sendTextMessage(number, null, msg, null, null);
Toast.makeText(this, "SMS Sent!", Toast.LENGTH_SHORT).show();
});
}
}

20. Write steps for customized permissions.


21. Explain the Android security model.
22. Discuss developer console with at least four features.
23. Elaborate the need of permissions in Android. Explain the permissions to set system
functionalitics like SEND-SMS, bluetooth
24. Explain the procedure of Geo-coding and reverse Geo-coding.
25. Develop an application to send and receive SMS (Write only Java and permission tag in
manifest file).
26. Develop a program to send and receive an Email.
27. Write a program to find the direction from user's current location to MSBTE, Bandra.
(Write only Java and manitest file).
(Note : Any other relevant logic to get the required output can also be considered.)
28. Develop an application to display Google map with user’s current location.
29. Define :
30. i) Fragment
ii) Broadcast receiver

You might also like