ch6 1
ch6 1
SMS telephony
• Android provides a class SmsManager to manage SMS operations such as sending data,
text, and pdu SMS messages.
• It requires the need SEND_SMS permission by mentioning this in the manifest file
<uses-permission android:name=“android.permission.SEND_SMS>
Methods
• Android location APIs make it easy to build location-aware applications, without needing to
focus on the details of the underlying location technology.
• This becomes possible with the help of Google Play services, which facilitates adding location
awareness to your app with automated location tracking, geofencing, and activity
recognition.
• A location may consist of a latitude, longitude, timestamp, and other information such as
bearing, altitude and velocity.
• Methods
To get the current location, create a location client which is LocationClient object, connect it to
Location Services using connect() method, and then call its getLastLocation() method.
This method returns the most recent location in the form of Location object that contains latitude
and longitude coordinates and other information.
To have location based functionality in your activity, you will have to implement two interfaces:
GooglePlayServicesClient.ConnectionCallbacks
GooglePlayServicesClient.OnConnectionFailedListener
To get an API key
The API key is a unique identifier that authenticates requests associated with the project for usage
and billing purposes. At least one API key must be associated with the project.
Click on the Google Cloud Platform home in the upper left corner
Click on Billing to make sure your billing details are up-to-date. If they are not, your Google Maps will
not work properly.
Once you’ve confirmed your billing is up-to-date, click on the Google Cloud Platform home in upper
left corner again.
If you want to use an existing project, select it from the list. Otherwise, select ‘Create a new project’
and enter a project name.
Click Create credentials and select API key. You will see a new dialog that displays the newly created
API key.
Click the Close button in the API key dialogue. Your new API key will be listed on
the Credentials page under API keys.
In android manifest file add the following as a child of <application> and insert it just before
</application>
Android provides facility to use and integrate google map in the application. It navigate location
direction, displays the current location, search location etc
Normal – this type of map displays typical road map, natural features like river and some features
built by human
Hybrid – this type of map displays satellite photograph data with typical road maps.
Satellite – this type displays satellite photograph but not road maps
Terrain – this type displays photographic data. This contain concour lines, colours and labels
Zoom controls
It has two buttons, ZoomIn and ZoomOut used to control zooming functionality
Methods of ZoomControls
In the google map instance method addMarker can be invoked by passing MarkerOptions as
parameter
Eg:
googleMap.addMarker(new MarkerOptions().position(TIMES_SQUARE));
Geocode and Reverse Geocoding
Geocoding is the process of transforming a street address or other description of a location into a
(latitude, longitude) coordinate. Reverse geocoding is the process of transforming a (latitude,
longitude) coordinate into a (partial) address.
The amount of detail in a reverse geocoded location description may vary, for example one might
contain the full street address of the closest building, while another might contain only a city name
and postal code.
The Geocoder class requires a backend service that is not included in the core android framework.
The Geocoder query methods will return an empty list if there no backend service in the platform.
Use the isPresent() method to determine whether a Geocoder implementation exists.
Geocoding is the process of transforming a street address or other description of a location into a
(latitude, longitude) coordinate. Reverse geocoding is the process of transforming a (latitude,
longitude) coordinate into a (partial) address.
The amount of detail in a reverse geocoded location description may vary, for example one might
contain the full street address of the closest building, while another might contain only a city name
and postal code.
The Geocoder class requires a backend service that is not included in the core android framework.
The Geocoder query methods will return an empty list if there no backend service in the platform.
Use the isPresent() method to determine whether a Geocoder implementation exists.
Android pursues to be the most safe and usable OS for mobile platforms by the following objectives
To achieve these objectives, android provides the following key security features
- Secure IPC
- App signing
- Using permissions
- Android application cannot do anything that would adversely impact the user experience or
any data on the device
- To make use of protected features of the device, one or more permissions <uses-
permission> tags should be declared in AndroidManifest.xml
- <uses-permission android:name=“android.permission.RECEIVE_SMS/>
- At application install time, permissions requested by the application are granted to it by the
package installer, based on checks against the signatures of the applications declaring those
permissions and/or interaction with the user.
- Using permissions
- No check with the user are done while an application is running: it either was granted a
permission when installed and can use the feature as desired or the permission was not
granted and any attempt to use the feature will fail without prompting the user
- For eg: the sendBroadcast(intent) method checks permissions as data is being delivered to
each receiver, after the method call has returned
- To enforce own permission, first declare them in the AndroidManifest.xml file using one or
more <permission> tag
- <permission
- Android:name=“name”
- Android:label=“@string/label”
- Android:description=“description”
- Android:permissionGroup = “android:permission-group.name”
- Android:protectionLevel = [“normal”|”dangerous”|”signature]
- Android:label-A name for the permission, one that can be displayed to users.As a
convenience, the label can be directly set as a raw string while programmer is developing
the application. However, when the application is ready to be published, it should be set as a
reference to a string resource, so that it can be localized like other strings in the user
interface.
- Android:name - The name of the permission. This is the name that will be used in code to
refer to the permission — for example, in a <uses-permission> element and the permission
attributes of application components
- Each protection level consists of a base permission type and zero or more flags. For Eg – the
dangerous protection level has no flags, In contrast, the protection level
“signature|privileged” is a combination of the signature base permission type and privileged
flag
- Values
- Normal - The default value. A lower-risk permission that gives requesting applications access
to isolated application-level features, with minimal risk to other applications, the system, or
the user. The system automatically grants this type of permission to a requesting application
at installation, without asking for the user's explicit approval (though the user always has the
option to review these permissions before installing)
- Values
- Signature - A permission that the system grants only if the requesting application is signed
with the same certificate as the application that declared the permission. If the certificates
match, the system automatically grants the permission without notifying the user or asking
for the user's explicit approval.
- Generate upload key for android app
- To publish an app in Google play store, first we need to generate signed APK version of our
application
- In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and
click Next.
- Below the field for Key store path, click Create new.
- On the New Key Store window, provide the following information for your keystore and key
Keystore
• Key store path: Select the location where your keystore should be created.
Key
• Password: Create and confirm a secure password for your key. This should be
different from the password you chose for your keystore.
• Validity (years): Set the length of time in years that your key will be valid. Your key
should be valid for at least 25 years, so you can sign app updates with the same key
through the lifespan of your app.
• Certificate: Enter some information about yourself for your certificate. This
information is not displayed in your app, but is included in your certificate as part of
the APK.
• To sign your app using Android Studio, and export an existing app signing key
• If you don’t currently have the Generate Signed Bundle or APK dialog open, click Build >
Generate Signed Bundle/APK.
• In the Generate Signed Bundle or APK dialog, select either Android App Bundle or APK and
click Next.
• Specify the path to your keystore, the alias for your key, and enter the passwords for both.
• If you don’t currently have the Generate Signed Bundle or APK dialog open, click Build >
Generate Signed Bundle/APK.
• In the Generate Signed Bundle or APK dialog, select either Android App Bundle or APK and
click Next.
• Specify the path to your keystore, the alias for your key, and enter the passwords for both.
• Click Next.
• In the next window, select a destination folder for your signed app, select the build type,
choose the product flavor(s) if applicable.
• Click finish
• After Android Studio finishes building your signed app, you can either locate or analyze your
app by clicking on the appropriate option in the pop-up notification.
Become a publisher
Publishing is the general process that makes your android applications available to users
When you publish an android application, you perform two main tasks
Preparing app for release is a multistep process with the following steps
- Become a publisher