Unit-6 Security and Application Deployment
Unit-6 Security and Application Deployment
Course Outcome:
Unit Outcomes:
Contents:
● Provides functionality to send and receive SMS (Short Message Service) messages.
● Allows applications to interact with the device's SMS capabilities.
Basic Requirements:
● SmsManager:
○ Handles sending SMS messages.
○ Provides methods like sendTextMessage() to send SMS.
● BroadcastReceiver:
○ Used to receive incoming SMS messages.
○ Listens for the android.provider.Telephony.SMS_RECEIVED broadcast.
● SmsMessage:
○ Represents an SMS message.
○ Provides methods to extract the sender's phone number, message body, etc.
Permissions:
<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="message"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SendSMS”
android:onClick="sendSMS"/>
</LinearLayout>
SMSDemo.java
public class SMSDemo extends AppCompatActivity
{
EditText ph,msg;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smsdemo);
ph=findViewById(R.id.PhoneNumber);
msg=findViewById(R.id.Message);
}
public void sendSMS(View view)
{
String phone=ph.getText().toString();
String text=msg.getText().toString();
SmsManager mgr=SmsManager.getDefault();
mgr.sendTextMessage(phone,null,text,null,null);
Toast.makeText(this,"sms sent!!",Toast.LENGTH_LONG).show();
}
}
Department of Computer Engineering 2 Mrs. Kulkarni D.P.
Mobile Application Development Unit-VI Security and Application Deployment
SMSReceiver.java(BroadcastReceiver)
public class SMSReceiver extends BroadcastReceiver
{
To use Google Maps in your application, you first need to create a new project in Google
Cloud Console.
Go to the Google Cloud Console, create a new project, and enable the Google Maps SDK for
Android.
Once enabled, you can generate an API key that will allow your app to access Google Maps
services.
Create new credentials for your app by selecting Create Credentials → API Key.
Restrict the API Key to your app’s package name to prevent unauthorized access.
Copy this key and use it in your app to authenticate your API requests.
}
}
Output :
● By default, zoom controls are enabled in Google Maps. If you want to enable them explicitly,
as
mMap.getUiSettings().setZoomControlsEnabled(true);
This will allow the user to zoom in and out of the map using on-screen buttons.
● You can navigate to a specific location on the map by using CameraUpdateFactory to move
the camera to the desired coordinates:
This will move the camera to New York City with a zoom level of 15.
6. Adding Markers
This will place a marker at the specified latitude and longitude with a title.
7. Getting Location
o <uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
o <uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
activity_current_location.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:id="@+id/main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CurrentLocation">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
CurrentLocation.java
public class CurrentLocation extends AppCompatActivity implements OnMapReadyCallback
{
private GoogleMap mMap;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_current_location);
SupportMapFragment smp = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
smp.getMapAsync(this);
}
Output :
Example of Geocoding:
You can get details like the user’s location, speed, altitude, etc., from the Location object
provided by the FusedLocationProviderClient:
if (location != null) {
● You can set up location updates to monitor the user’s movement in real-time using
FusedLocationProviderClient. This is useful for navigation apps or when you need to track
the user’s location continuously.
fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback,
Looper.getMainLooper());
⎯ App Signing:
o This confirms who created the app and helps verify it's not tampered with.
⎯ Permissions at Installation:
o Apps must tell you what resources they need (like internet access) when you install
them.
o This is to ensure that you are aware of what an application is accessing.
⎯ Purpose of Permissions:
o Protects user privacy and system security.
o Apps must request permission for sensitive data & system features.
o Some permissions require user approval, while others are auto-granted.
⎯ Types of Permissions
1. Normal Permissions (Low-risk)
o Allow access to resources outside the app sandbox.
o Normal permissions allow an app to access non-sensitive system features that do not
affect user privacy or the functionality of other apps.
o Automatically granted at install time (No user approval needed).
o Example: Setting the time zone,Vibrate,Internet,Access Network state.
2. Signature Permissions (Restricted to Same Developer)
o Only granted when both apps are signed by the same developer certificate.
o Used mainly for internal communication between apps developed by the same
company or developer..
o Granted at install time without user interaction.
o Example : Read logs, Install Shortcuts etc.
activity_current_location.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"
android:id="@+id/main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CurrentLocation">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
CurrentLocation.java
public class CurrentLocation extends AppCompatActivity implements OnMapReadyCallback
{
private GoogleMap mMap;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_current_location);
getSupportFragmentManager().findFragmentById(R.id.map);
smp.getMapAsync(this);
}