
Answer & Explanation:QuestionsAnswer and explain the following questions:1. What file type is the Android manifest file?a. HTMLb. XMLc. TXTd. CSV 2. What symbol is used to specify that a class belongs to the package name specified in the manifest?a. #b. _c. .d. $ 3. When using the
madd_ch6_v02.pdf
Unformatted Attachment Preview
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Dr. Jose Garcia-Rubia
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Overview
Use the Android manifest file for configuring
Android applications
Manage the application’s name and icon with the
Android manifest file
Enforce application system requirements by
targeting specific devices
Register activities in the Android manifest
Work with permissions
Explore additional manifest file settings
2
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Configuring Android Applications
Using the Android Manifest
What is the Android manifest file?
Specially formatted XML file required for each
Android application
Defines application name
Defines components the application relies on
Defines permissions the application requires to
run
Named AndroidManifest.xml
Example: SimpleHardware
Project tab in Active Tool window. Android tab in app.
Manifests folder.
3
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Configuring the Android Manifest
AndroidManifest.xml information is used by the Android
system to
Install and upgrade the application package
Display the application’s name, description, and icon to users
Specify application system requirements
Device configurations required (e.g., D-pad navigation)
Platform features relied upon (e.g., multitouch)
Specify features required by the application for market filtering
Register application activities and when they should be launched
Manage application permissions
Configure and define services, broadcast receivers, and content
providers
Specify intent filters for activities, services, and broadcast
receivers
Enable application settings and configurations
4
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Editing the Android Manifest File
Use Android Studio to manually edit the manifest
XML.
Android manifest files include a single
tag with a single tag.
5
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Editing the Manifest File Manually
Here is a summary of what this file tells us about the
SimpleHardware application:
The package name is
com.introtoandroid.simplehardware.
The application name is stored in the resource string
@string/app_name within the res/values/strings.xml
resource file.
The application icon is the file called ic_launcher found in
the /res/mipmap-* directory.
The application has four activities.
SimpleHardwareActivity is the primary entry point.
Requires the following permission: battery stats.
Uses the following device features: accelerometer,
barometer, compass, gyroscope, light, proximity,
stepcounter, and stepdetector.
6
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Managing Your Application’s
Identity
7
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Setting the Application Name and
Icon
Overall application settings are configured with the
tag of the Android manifest file.
Here, you set information such as the application
icon (android:icon) and friendly name
(android:label).
These settings are attributes of the
tag.
You can also set optional application settings as
attributes in the tag:
android:description
android_debuggable=”true”
8
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Setting the Application Name and
Icon (Cont’d)
9
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Enforcing Application System
Requirements
System requirements can be defined and enforced in
the Android manifest file.
When an application is installed on a device, the
Android platform checks these requirements and will
error out if necessary.
The Google Play store uses information in the
Android manifest file to filter which applications to
offer to which devices so that users install
applications that work on their devices.
10
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Enforcing Application System
Requirements (Cont’d)
Developers can configure some application system
requirements in the manifest:
Android SDK versions supported
Platform features used
Hardware configurations required
Screen sizes and pixel densities supported
External libraries
11
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Enforcing Application Platform
Requirements
Android devices have different hardware and
software configurations:
Some have built-in keyboards.
Others rely on the software keyboard.
Some support the latest 3D graphics libraries.
Others provide little or no graphics support.
The Android manifest file has several informational
tags for flagging the system features and hardware
configurations supported or required by an Android
application.
12
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Supported Input
Methods
For specifying hardware and software input methods
There are different configuration attributes for five-way
navigation:
Hardware keyboard and keyboard types
Directional pad
Trackball
Wheel
Touchscreen settings
There is no “OR” support!
What if you want to support many input configurations?
Define multiple tags
13
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Supported Input
Methods (Cont’d)
14
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Required Device
Features
The tag is used to specify features
your application needs to run properly.
These settings are for informational purposes only.
Android does not enforce these settings.
Publication channels such as Google Play use
this information to filter the applications available
to a given user.
Other applications might check this information
as well.
15
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Required Device
Features (Cont’d)
16
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Required Device
Features (Cont’d)
One common reason to use the
tag:
It specifies the OpenGL ES versions supported.
All applications function with OpenGL ES 1.0 by
default.
However, if your app requires features available in
later versions of OpenGL ES (such as 2.0), you
must specify this feature.
Do this with the android:glEsVersion attribute
of .
Specify
the lowest version of OpenGL ES that the
application requires.
17
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Supported Screen Sizes
Android devices come in many shapes and sizes.
Screen sizes and pixel densities vary.
The tag can be used to specify the types
of screens supported.
Android categorizes screen types in terms of:
Sizes
Small, normal, large, and xlarge
Pixel density
LDPI, MDPI, HDPI, XHDPI, XXHDPI, and XXXHDPI
Or, rather, low-, medium-, high-, extra-high-, extra-extrahigh-, and extra-extra-extra-high density displays
18
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Specifying Supported Screen Sizes
(Cont’d)
19
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Working with External Libraries
You can register shared libraries your application
links to within the Android manifest file.
Every application is linked to the standard Android
packages (such as android.app) and is aware of its
own package.
However, if your application links to additional
packages, register them within the
tag using .
20
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Working with External Libraries
(Cont’d)
21
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Other Application Configuration
Settings and Filters
This tag is used to specify the GL texture compression
format supported.
It is used by applications that use the graphics libraries and
are intended to be compatible only with devices that
support a specific compression format.
This tag is used solely by the Google Play store to restrict
installation of your application to devices with specific
screen sizes.
It is not checked by Android and usage is discouraged
unless you absolutely need to restrict the installation to
certain devices.
22
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Activities in the Android
Manifest
Each Activity within the application must be defined with an
tag.
The following XML excerpt registers an Activity class called
SensorsActivity:
This Activity must be defined as a class within the application package,
in this case:
com.introtoandroid.simplehardware
23
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Designating an Entry Point
Activity Using an Intent Filter
You can designate an Activity class as the primary
entry point.
Just configure an intent filter, such as , with the following options:
MAIN action type
The LAUNCHER category
24
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Designating an Entry Point Activity
Using an Intent Filter (Cont’d)
25
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Configuring Other Intent Filters
Android uses intent filters to resolve implicit intents,
that is, intents that do not have a specific Activity
or other component to launch.
Intent filters can be applied to activities, services,
and broadcast receivers.
An intent filter declares that this component is
capable of handling or processing a specific type
of Intent when it matches the filter’s criteria.
Different applications have the same types of intent
filters and are able to process the same types of
requests.
26
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Configuring Other Intent Filters
(Cont’d)
27
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Other Application
Components
All application components must be defined within the Android
manifest file.
In addition to activities, all services and broadcast receivers
must be registered within the Android manifest file.
Services are registered using the tag.
Broadcast receivers are registered using the
tag.
Content providers are registered using the tag.
Services and broadcast receivers use intent filters.
If your application acts as a content provider, it must declare
this capability using the tag.
28
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Working with Permissions
Android has been locked down so that applications
have limited capability to adversely affect operations
outside their process space.
Instead, Android applications run within the bubble
of their own virtual machine:
With their own Linux user account
And related permissions
Example: SimplePermissions
Project tab in Active Tool window. Android tab in app.
Manifests folder.
29
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Requires
Android applications have no permissions by
default.
Instead, permissions for shared resources or
privileged access—whether it’s shared data, such
as the Contacts database, or access to underlying
hardware, such as the built-in camera—must be
explicitly registered within the Android manifest
file.
30
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Requires (Cont’d)
For devices running versions of Android prior to
Marshmallow 6.0 API Level 23, these permissions
are granted when the application is installed.
For devices running Android Marshmallow 6.0 API
Level 23 and newer, permissions with a level of
PROTECTION_NORMAL, and some with
PROTECTION_SIGNATURE, are granted at installation.
Those permissions with a PROTECTION_DANGEROUS
must be requested and verified at runtime.
31
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Requires (Cont’d)
32
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
Android Marshmallow introduced a new permission
model allowing users to install your application and
to accept your application’s permissions once
interaction occurs with the features that require
them.
This new permission model is important because it
reduces the amount of friction permissions may
have caused in the past, such as users abandoning
the installation of your application because they are
not comfortable accepting a particular permission.
33
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
With the Android Marshmallow permission model, users
do not need to grant permissions prior to installing,
allowing them to install and start interacting with your
application.
Once users come across a feature that requires a particular
permission, they are presented with a dialog requesting them to
grant the permission.
If the permission is granted, the system notifies the application
and permission is then granted to the users. If the permission is
not granted, the users will not be able to access the particular
functional area of your application that requires the denied
permission.
Permissions are declared as normal with the
tag in the Android manifest file.
34
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
Your application’s code is where you check to see if
the permission has been granted.
This permission model allows users to revoke
access to particular permissions in the application
settings, without having to uninstall your
application.
Even if users grant a particular permission, they are
able to revoke permissions at anytime, so your
application must always check if a particular
permission is granted, and if not, make a request for
the permission.
35
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
compile ‘com.android.support:support-v4:23.0.0’
compile ‘com.android.support:appcompat-v7:23.0.0’
36
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
public class PermissionsActivity extends
AppCompatActivity implements
ActivityCompat.OnRequestPermissionsResultCallback {
// Activity code here
}
37
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission(this,
Manifest.permission.WRITE_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
Log.i(DEBUG_TAG, “Contact permissions not granted. Requesting
permissions.”);
ActivityCompat.requestPermissions(GridListMenuActivity.this, {
Manifest.permission.READ_CONTACTS,
Manifest.permission.WRITE_CONTACTS}, 0);
} else {
Log.i(DEBUG_TAG,
“Contact permissions granted. Displaying contacts.”);
// Do work here
}
38
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Requesting Permissions at Runtime
(Cont’d)
•
•
This if statement checks if the READ_CONTACTS and
WRITE_CONTACTS permissions have been granted, and if not, calls the
requestPermissions() method of ActivityCompat.
You then must implement the OnRequestPermissionsResultCallback by
overriding the onRequestPermissionsResult() method in your Activity as
shown below:
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_CONTACTS) {
Log.d(DEBUG_TAG, “Received response for contact permissions request.”);
// All Contact permissions must be checked
if (verifyPermissions(grantResults)) {
// All required permissions granted, proceed as usual
Log.d(DEBUG_TAG, “Contacts permissions were granted.”);
Toast.makeText(this, “Contacts Permission Granted”,
Toast.LENGTH_SHORT).show();
} else {
Log.d(DEBUG_TAG, “Contacts permissions were denied.”);
Toast.makeText(this, “Contacts Permission Denied”,
Toast.LENGTH_SHORT).show();
}
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
39
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Enforces
Applications can also define and enforce their own
permissions via the tag.
These
are used by other applications.
Permissions must be described and then applied to
specific application components, such as activities
using the android:permission attribute.
40
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Enforces (Cont’d)
Permissions can be enforced at several points:
When starting an Activity or Service
When
accessing data provided by a content
provider
At the method call level
When sending or receiving broadcasts by an
Intent
41
Mobile Applications Design and Development
Chapter 6. Defining the Manifest
Registering Permissions Your
Application Enforces (Cont’d)
Permissions can have three primary protection
levels: normal, dangerous, and signature.
Normal is a good default for …
Purchase answer to see full
attachment
Order a plagiarism free paper now. We do not use AI. Use the code SAVE15 to get a 15% Discount
Looking for help with your ASSIGNMENT? Our paper writing service can help you achieve higher grades and meet your deadlines.

Why order from us
We offer plagiarism-free content
We don’t use AI
Confidentiality is guaranteed
We guarantee A+ quality
We offer unlimited revisions