Mobile Application Development
UNIT 02: ANDROID APPLICATION DESIGN ESSENTIALS
Anatomy of an Android application
Anatomy of an Android application refers to the essential structural components that make up
the application as a whole. The anatomy of an Android application refers to the fundamental
building blocks or components of an Android application and how they work together to
create a functional software program. There are the following main components of an android
app:
1. Activities: Activities are said to be the presentation layer of our applications. The Ul of our
application is bulk around one or more extensions of the Activity class. By using Fragments
and Views, activities set the layout and display the output and also respond to the user's
actions. An activity is implemented as a subclass of class Activity.
public class MainActivity extends Activity {
2. Services: Services are like invisible workers of our app. Tasks that do not require user
interaction can be encapsulated in a service. These components ran at the backend, updating
your data sources and Activities, triggering Notifications, and also broadcast Intents. They
also perform some tasks when applications are not active. A service can be used as a subclass
of class Service:
public class ServiceName extends Service (
3. Content Providers: It is used to manage and persist the application data also typically
interacts with the SQL database. They are also responsible for sharing the data beyond the
application boundaries. The Content Providers of a particular application can be configured to
allow access from other applications, and the Content Providers exposed by other
applications can also be configured. A content provider should be a sub-class of the class
ContentProvider
public class ContentProviderName extends ContentProvider (
public void onCreate(){}
4. Broadcast Receivers: They are known to be intera Isteners as they enable your application
to listen to the broadcasts that satisfy the matching criteria specified by us.
Broadcast Receivers make our application react to any received Intent thereby making them
perfect for creating event-driven applications.
5. Intents: It is a powerfil inter-application message-passing framework. They are
extensively used throughout Android. Intents can be used to start and stop Activities and
Services, to broadcast messages system-wide or to an explicia Activity, Service of Broadcast
Receiver or to request action be performed on a particular piece of data.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
6. Widgets: These are the small visual application components that you can find on the home
screen of the devices. They are a special variation of Broadcast Receivers that allow us to
create dynamic, interactive application components for users to embed on their Home Screen
7. Notifications: Notifications are the application alerts that are used to draw the user's
attention to some particular app event without stealing focus or interrupting the current
activity of the user. They are generally used to grab user's attention when the application is
not visible or active, particularly from within a Service or Broadcast Receiver.
Examples: E-mail popups, Messenger popups, etc.
Android terminologies
XML: In Android, XML is used for designing the application's Ul like creating
layouts, views, buttons, text fields etc, and also used in passing data feeds from the
internet.
View: A view is an Ul which occupies rectangular area on the screen to draw and
handle user events.
Layout: Layout is the parent of View it arrange all the views in a proper mauwer on
the screen.
Activity: An activity can be referred as your device's screen which you see user can
place Ul elements in any order in the created window of user's choice.
Emulator: An emulator is an Android virtual device through which you can select the
target Android version or platform to run and test your developed application
Manifest file: Manifesto file acts as a metadata for every application this fie contains
all the essential information about the application like app icon, app name, buncher
activity and required permissions etc.
Service: Service is an application component that can be used for long-running
background processes. It a not bound with any activity as there is no Ul. Any other
application component can start a service and this service will continue to run even
when the user switches from one application to another.
Broadcast receiver: Broadcast receiver is another building block of Android
application development which allows you to register for system and application
events. It works in such a way that even the event triggers for the first time all the
registered receivers through this broadcast receiver will get notified for all the events
by Android runtime.
Content providers: Content providers are used to share data between two
applications this can be implemented in two ways:
1. When you want to implement the existing content provider is another application.
2. When you want to create a new content provider that can share its data with other
applications.
Intent: Intent is a messaging object which can be used to communicate between two
or more components like activities, services, broadcast receiver etc. Intent can also be
used to start an activity or service or to deliver a broadcast message.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
APK: The APK (Android Package) file is the package file format used by the Android
operating system for distributing and installing applications. It contains all the
necessary files and resources required to run the application on an Android device.
Gradle: Gradle is the build automation tool used for Android app development. It
manages project dependencies, compiles source code, and produces the APK
(Android Package) file for deployment.
Android Context
"Context" in Android refers to the environment in which your app is currently running. It
provides essential information about your app's surroundings and allows your app to interact
with the system and other apps.
Imagine you're at a party: The "context" would be everything around you at that party the
people, the music, the decorations, etc. Similarly, in an Android app, the context provides
information about things like the current screen, user settings, resources, and more.
Here's a real-time example:
Let's say you're developing a weather app. When your app & launched, it needs to know
various things like the user's location, the current time, and maybe even the user's preferences
(like temperature units Celsius or Fahrenheit). All this information is provided by the context.
So, in this case:
The user's location could be obtained from the context to fetch accurate weather data.
The current time could be retrieved from the context to display the correct forecast.
User preferences, such as temperature units, could be accessed from the context to
customize the app's display.
The context in Android is like the background information your app needs to understand its
current situation and function properly, much like you need to know what's going on at a
party to have a good time!
Types of Android Context
1. Application Context
2. Activity Context
3. Service Context
4. Broadcast receiver Context
5. Fragment Receiver
6. View Receiver
In Android, there are several types of contexts, each serving different purposes and having
different lifecycles. Here are some of the main types:
Ms. T. Nagamani CSE Dept.
Mobile Application Development
1. Application Context: This context represents the entire application and is tied to the
lifecycle of the application. It's commonly used for global access to application-level
resources, such as assets and preferences. You can obtain it using getApplicationContext().
For example, if we want to access a variable throughout the android app, one has to use it via
getApplicationContext().
import [Link];
public class GlobalExampleclass extends Application (
private String globalName;
private String globalEmail;
public String getName() (
return globalName;
public void setName (String aName) {
globalName = aName;
public String getEmail() {
return globalEmail;
public void setEmail(String aEmail) {
globalEmail = aEmail;
List of functionalities of Application Context:
Load Resource Values
Start a Service
Bind to a Service
Send a Broadcast
2. Activity Context: This text is tied to the lifecycle of an activity. It's typically used when
you need access to resources that are tied to a specific activity, like layouts of localized
strings. You can obtain it using this inside an activity or by calling getContext() from within a
Ms. T. Nagamani CSE Dept.
Mobile Application Development
view. Suppose you have an activity where you want to inflate a layout or start a new activity.
You would use the activity context for these operations.
Here's an example:
For example, EnquiryActivity refers to Enquiry Activity only and AddActivity refers 10
AddActivity only. It is tied to the life cycle of activity. It is used for the current Context. The
method of invoking the Activity Context is getContext(). Some use cases of Activity Context
are:
i The user is creating an object whose lifecycle is attached to an activity.
ii. Whenever inside an activity for UI-related kind of operations like toast, dialogue,
etc.,
getContext(): It returns the Context which is linked to the Activity from which it is called.
This is useful when we want to call the Context from only the current running activity.
@Override
public void onItemClick(AdapterView<?> parent, View view, int pos,
long id) {
// [Link]() refers to the current activity view
// Here it is used to start the activity
intent Intent = new Intent([Link](), <your java
classname>::[Link]);
[Link](pid, ID);
[Link]().startActivity(intent);
List of Functionalities of Activity Context:
Load Resource Values
Layout Inflation
Start an Activity
Show a Dialog
Start a Service
Bind to a Service
Send a Broadcast
Register BroadcastReceiver
3. Service Context: This context is similar to the application context but is tied to a specific
service. It's often used in background services for accessing resources or performing
Ms. T. Nagamani CSE Dept.
Mobile Application Development
operations that require a context. You can obtain it using this inside a service or by calling
getContext() from within a service.
4. Broadcast Receiver Context: This context is passed to a BroadcastReceiver's onReceive()
method when it's triggered by a broadcast. It's typically used to perform operations in
response to system-wide events, such as receiving a message or connectivity changes.
5. Fragment Context: Each fragment in an Android app has its own context, which is tied to
the lifecycle of the fragment. It's used for accessing resources or perfiorming operations
within the fragment. You can obtain it using getContext() within a fragment.
6. View Context: This context is typically used within custom views or view elements. It
provides access to resources and allows for inflating layouts specific to that view, You can
obtain it using getContext() from within a view..
Android Activities
In Android, an activity is a fundamental component of an application's user interface. It
represents a single screen with a user interface that the user can interact with Activities play a
crucial role in the navigation and flow of an Android application, as they provide the entry
point for users to perform various tasks and interact with the app's functionality.
Each activity goes through various stages or a lifecycle and is managed by activity stacks. So,
when a new activity starts, the previous one always remains below it. There are four stages of
an activity.
1. If an activity is in the foreground of the screen ie at the top of the stack, then it is said to be
active or running. This is usually the activity that the user is currently interacting wah
2. If an activity has lost focus and a non-full-sized or transparent activity has focused on top
of your activity. In such a case either another activity has a higher position in multi-window
mode or the activity itself is not focusable in the current window mode. Such activity is
completely alive.
3. If an activity is completely hidden by and activity, it is stopped or hidden It still retains all
the information, and as its window is hidden thus it will often be kiled by the system when
memory is needed elsewhere.
4. The system can destroy the activity from memory by either asking it to finish or simply
killing its process. When & is displayed again to the user, it must be completely restarted and
restored to its previous state.
Activity Lifecycle
Activities in Android have a well-defined lifecycle, consisting of several states inchading
Created, Started, Resaned, Paused, Stopped, and Destroyed. Understanding this fecycle is
Ms. T. Nagamani CSE Dept.
Mobile Application Development
crucial for managing the behavior of your app across different states. For cach stage, android
provides us with a set of 7 methods that have their own significance for each stage in the life
cyck. Below figure shows different stages and methods that shows the path of migration
whenever an app switches from one state to another.
1. onCreate(): It is called when the activity is first created. This is where all the static work is
done like creating views, binding data to lists, etc. This method also provides a Bundle
containing its previous frozen state, if there was one.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
2. onStart(): It is invoked when the activity is visible to the user. It is followed by
onResume() if the activity is invoked from the background. It is also invoked after onCreate()
when the activity is first started.
3. onRestart(): It is invoked after the activity has been stopped and prior to its starting stage
and thus is always followed by onStart() when any activity is revived from background to on-
screen.
4. onResume(): It is invoked when the activity starts interacting with the user. At this point,
the activity is at the top of the activity stack, with a user interacting with it. Always followed
by onPause() when the activity goes into the background or is closed by the user.
5. onPause(): It is invoked when an activity is going into the background but has not yet been
killed. It is a counterpart to onResume(). When an activity is launched in front of another
activity, this callback will be invoked on the top activity (currently on screen). The activity,
under the active activity, will not be created until the active activity's onPause() returns, so it
is recommended that heavy processing should not be done in this part.
6. onStop(): It is invoked when the activity is not visible to the user. It is followed by
onRestart() when the activity is revoked from the background, followed by onDestroy() when
the activity is closed or finished, and nothing when the activity remains on the background
only. Note that this method may never be called, in low memory situations where the system
does not have enough memory to keep the activity's process running after its onPause()
method is called.
7. onDestroy(): The final call received before the activity is destroyed. This can happen
either because the activity is finishing (when finish() is invoked) or because the system is
temporarily destroying this instance of the activity to save space. To distinguish between
these scenarios, check it with is Finishing() method.
Android - Services
A service is a component that runs in the background to perform long-running operations
without needing to interact with the user and it works even if application is destroyed. A
service can essentially take two states:
1. Started: A service is started when an application component, such as an activity, starts it
by calling startService(). Once started, a service can run in the background indefinitely, even
if the component that started it is destroyed.
2. Bound: A service is bound when an application component binds to it by calling
bindService(). A bound service offers a chent-server interface that allows components to
interact with the service, send requests, get results, and even do so across processes with
interprocess communication (IPC).
Android Service Lifecycle
Ms. T. Nagamani CSE Dept.
Mobile Application Development
A service has life cycle callback methods that you can implement to monitor changes in the
service's state and you can perform work at the appropriate stage. The following diagram on
the left shows the life cycle when the service is created with startService() and the diagram on
the right shows the life cycle when the service is created with bindService(): (image courtesy:
[Link])
1. onStartCommand(): The system calls this method when another component, such as an
activity, requests that the service be started, by calling startService(). If you implement this
method, it is your responsibility to stop the service when its work is done, by calling
stopSelf() or stopService() methods.
2. onBind(): The system calls this method when another component wants to bind with the
service by calling bindService(). If you implement this method, you must provide an interface
that clients use to communicate with the service, by returning an Hinder object.
You must always implement this method, but if you don't want to allow binding, then you
should return null.
[Link](): The system calls this method when all clients have disconnected from a
particular interface published by the service
4. onRebind(): The system calls this method when new clients have connected to the service,
after i had previously been notified that all had disconnected in its onUnbind(Intent)
Ms. T. Nagamani CSE Dept.
Mobile Application Development
5. onCreate(): The system calls this method when the service is first created using
onStartCommand() or onBind(). This call is required to perform one-time set-up.
6. onDestroy(): The system calls this method when the service is no longer used and is
being destroyed. Your service should implement this to clean up any resources such as
threads, registered listeners, receivers, etc.
Android Intents
Intents are a fundamental component of the Android system, used for communication
between different components of an application and between different applications. They
faciătate asynchronous communication and enable various actions such as starting activities,
services, or broadcasting messages.
An intent is an abstract description of an operation to be performed. It can be used to
request an action from another component of the Android system, either within the same
application or across different applications
Intent filters are a very powerful feature of the Android platform. They provide the
ability to launch an activity based not only on an explicit roquest, but also an implicit one.
For example, an explicit request might tell the system to "Start the Send Email activity in the
Gmail app". By contrast, an implicit request tells the system to "Start a Send Email screen in
any activity that can do the job." When the system Ul asks a user which app to use in
performing a task, that's an intent filter at work. You can take advantage of this feature by
declaring an attribute in the element. The definition of this element inchades an element and,
optionally, a element and/or an element. These elements combine to specify the type of intcot
to wach your activity can respond. For example, the following code snippet shows how to
configure an activity that serais text data, and receives requests from other activities to do so:
<activity android:name=". ExampleActivity"
android:icon="@drawable/app_icon">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]. DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
In this example, the element specifies that this activity sends data. Declaring the element as
DEFAULT enables the activity to receive launch requests. The element specifies the type of
Ms. T. Nagamani CSE Dept.
Mobile Application Development
data that this activity can send. The following code snippet shows how to call the activity
described above:
val sendintent = Intent().apply(
action = Intent.ACTION_SEND
type = "text/plain"
putExtra ([Link] TEXT, textMessage)
}
startActivity(sendIntent)
Types of Android Intents
There are two types of intents:
1. Explicit intents: Explicit intents specify which application will satisfy the intent, by
supplying either the target app's package name or a fully-qualified component class name.
You'll typically use an explicit intent to start a component in your own app, because you
know the class name of the activity or service you want to start. For example, you might start
a new activity within your app in response to a user action, or start a service to download a
file in the background.
2. Implicit intents: Implicit intents do not name a specific component, but instead declare a
general action to perform, which allows a component from another app to handle it. For
example, if you want to show the user a location on a map, you can use an implicit intent to
request that another capable app show a specified location on a map.
The following figure shows how an intent is used when starting an activity. When the Intent
object names a specific activity component explicitly, the system immediately starts that
component. It also shows how an implicit is delivered through the system to start another
activity.
Activity A: Creates an Intent with an action description and passes it to startActivity().
Ms. T. Nagamani CSE Dept.
Mobile Application Development
The Android system searches all apps for an intent filter that matches the intent. When
a match is found.
The system starts the matching activity (Activity B) by invoking its onCreate()
method and passing it to the intent.
Using Intent Filters
Intent filters in Android are used to declare the types of intents that a component (such as an
activity, service, or broadcast receiver) can respond to. By specifying intent filters, you define
the conditions under which your component should be activated.
Receiving and Broadcasting Intents
Receiving and broadcasting intents in Android is a fundamental part of buikling interactive
and responsive applications. Here's a breakdown of how you can receive and broadcast
intents in Android:
1. Activity Intent Filter. An activity intent filter in Android is a declaration within the
[Link] file that specifies the types of intents that an activity can respond to. By
defining internt filters for activities, you determine the conditions under which the activity
should be launched or activated.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]"
/>
</intent-filter>
</activity>
In this example,
<action element specifies the action that the activity can handle.
[Link]. MAIN indicates that the activity is the main entry point of the
application.
<category> element specifies the category of the intent.
[Link]:LAUNCHER indicates that the activity should appear in
launcher as an entry point for the application.
2. Service Intent Filter: In Android, service intent filters are not commonly used in the same
way as activity intent fiters. Services typically do not have intent filters declared in the
manifest file. Instead, they are typically started or bound explicitly using intents from other
components (such as activities or broadcast receivers) or system events.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
<service android:name=". MyService">
<intent-filter>
<action android:name="[Link] START
SERVICE”
/>
</intent-filter>
</service>
In this example:
The service component is declared to handle intents with the action
[Link].ACTION_START_SERVICE. This means that when an intent with this action
is sent, it will activate the specified service.
3. Broadcast Receiver Intent Filter: In Android, broadcast receivers often utilize intent
filters to specify the types of broadcast intents they are interested in receiving. Here's how
you can define a broadcast receiver intent filter within the [Link] file:
<receiver android: name " MyBroadcastReceiver">
<intent-filter>
<action
android:name=" [Link] COMPLETED"/>
</intent-filter>
<</receiver>
In this example:
The broadcast receiver is registered to listen for the
[Link].BOOT_COMPLETED action. This means that when the device
completes booting, the specified broadcast receiver will be activated.
Receiving Intents:
1. Broadcast Receivers: A broadcast receiver is a component that listens for a to broadcasted
intents. To create a broadcast receiver: responds
Extend the BroadcastReceiver class.
Override the onReceive() method to define the behavior when the receiver receives an
intent.
Register the receiver either statically in the manifest file or dynamically in code using
registerReceiver().
Ms. T. Nagamani CSE Dept.
Mobile Application Development
2. Manifest-registered Receivers: If you register a receiver in the manifest fie, it will
automatically receive intents broadcasted by the system, even if your app is not currently
running
<receiver android:name=". MyBroadcastReceiver">
<intent-filter>
<action
android:name="[Link].ACTION_NAME" />
</intent-filter>
</receiver>
3. Dynamic Receivers: You can ako register a receiver dynamically in code. This allows you
to register and unregister the receiver based on the lifecycle of your app.
IntentFilter filter = new
IntentFilter ("[Link].ACTION_NAME");
Broadcast Receiver receiver new MyBroadcastReceiver();
[Link](receiver, filter):
Broadcasting Intents:
1. Creating Intents: To broadcast an intent, create an Intent object with the appropriate
action, data, and extras if needed.
Intent intent new Intent("[Link] NAME [Link]("key",
"value"
2. Sending Broadcasts: You can broadcast the intent using one of the following
Methods:
send Broadcast(Intent): Sends the intent to all interested broadcast receivers.
send Ordered Broadcast(Intent): Sends the intent to receivers in a specific order
defined by their priority.
sendStickyBroadcast(Intent): Sends a sticky broadcast, which stays active even
after the broadcast is complete and can be received by future broadcast receivers.
Example: Let's say you want to create a broadcast receiver that listens for a custom action
and displays a toast message when it receives the intent.
1. Create BroadcastReceiver:
public class MyBroadcastReceiver extends BroadcastReceiver (
@Override
Ms. T. Nagamani CSE Dept.
Mobile Application Development
public void onReceive (Context context, Intent intent) (
String message [Link]("key");
[Link] (context, message,
[Link] SHORT).show();
2. Register BroadcastReceiver:
Manifest registration: Add the receiver to the manifest file with the appropriate intent fiker.
Dynamic registration Register the receiver in your activity's onCreate() method and
unregister it in onDestroy().
Intent intent new
Intent("[Link] NAME");
[Link]("key", "Hello from Broadcast!");
sendBroadcast (intent);
With these steps, your broadcast receiver will listen for the custom intent and display a toast
message when it receives the broadcasted intent.
Android Manifest File and its common settings
Every project in Android includes a Manifest XML file, which s [Link],
located in the root directory of its project hierarchy. The manifest file is an important part of
our app because it defines the structure and metadata of our application, its components, and
its requirements. This file includes nodes for each of the Activities, Services, Content
Providers, and Broadcast Receivers that make the application, and using Intent Filters and
Permissions determines how they coordinate with each other and other applications. The
manifest file also specifies the application metadata, which includes is icon, version number,
themes, etc. Here are some common settings and elements found in the [Link]
file:
1. Package Name: The package attribute in the <manifest element specifies the unique
identifier for the application package. It must be unique across all applications installed on
the device
manifest, amin:android="[Link]
package [Link]”>
2. Application Components: Activities, services, broadcast receivers, and content providers
are declared as components of the <application> element.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
<application
android:allowBackup"true"
android:icon="@drawable/app_icon"
android:label="@string/app name">
<!-- Activity declarations ->>
<!-- Service declarations -->
<!-- Receiver declarations
<!-- Provider declarations -->
</application>
3. Activity Declaration: Each <activity element defines an activity component of the
application. Activities can have intent filters to specify how they are lunched.
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]. LAUNCHER" />
</intent-filter>
</activity>
4. Service Declaration: Services are declared using the <service> element. They perform
background tasks without a user interface.
<receiver
android:name". MyBroadcastReceiver"
android:exported-"true">
<intent-filter>
<action android:name="[Link]
COMPLETED"/>
</intent-filter>
</receiver>
Ms. T. Nagamani CSE Dept.
Mobile Application Development
5. Broadcast Receiver Declaration: Broadcast receivers listen for and respond to broadcast
messages. They are declared using the <receiver element.
<receiver
android:name=".MyBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="[Link]
COMPLETED"/>
</intent-filter>
</receiver>
6. Content Provider Declaration: Content providers manage access to a shared set of
application data. They are declared using the provider element
<provider
android:name=".MyContentProvider"
android:authorities="[Link]
android:exported="false">
</provider>
7. Permissions: The <uses-permission element specifies the permissions required by the
application to access certain features or resources on the device.
<uses-permission android:name="[Link]"/>
<uses-permission
android:name="[Link] NETWORK STATE" />-
8. Application Metadata: Metadata tags can be used to provide additional information about
the application
<meta-data
android:name="[Link].APPLICATION_ID"
android: value="ca-app-pub-1234567890"/>
9. Versioning and Targeting: Attributes like android:versionCode and android versionName
specify the version information of the application.
<manifest
xmins:android="[Link]
Ms. T. Nagamani CSE Dept.
Mobile Application Development
package [Link]"
android:versionCode="1"
android:versionName="1.0">
10. Minimum SDK Version: The android aminSdkVersion attribute specifies the mini API
level required by the application to run,
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="31" />
Android Permissions
Permissions in Android are a crucial aspect of security and privacy management,
allowing applications to access sensitive data and perform restricted operations. Android
applications need to declare the permissions they require in their manifest files.
Declaring Permissions
Permissions are declared in the [Link] file using the uses permission element.
Each permission specifies a specific operation or resource that the application needs access
to.
<uses-permission android:name="[Link]" />
Permission Levels
Permissions in Android are categorized uno different levels based on their sensitivity and
potential risk to user privacy:
Normal Permissions: These permissions are granted automatically when the application is
installed and do not require explicit user consent.
Dangerous Permissions: These permissions are considered sensitive and require the user to
grant permission at runtime on devices running Android 6.0 (API level 23) and higher.
Requesting Dangerous Permissions
For dangerous permissions, developers need to request permission from the user at runtime.
This involves checking whether the permission is already granted and, if not, requesting it
from the user.
// Check if permission is not granted
if ([Link](this, [Link])
{
PackageManager. PERMISSION_GRANTED) (
Ms. T. Nagamani CSE Dept.
Mobile Application Development
// Request permission
[Link] (this,
new String[] ([Link]),
MY PERMISSIONS REQUEST CAMERA);
Handling Permission Results
Afler requesting permissions at runtime, the application receives the result in the
onRequestPermissions Result() method. Developers should handle permission grant or denial
accordingly.
@Override
public void onRequestPermissionsResult (int requestCode, @NonNull
String[] permissions. @NonNull int[] grantResults) (
if (requestCode = = MY PERMISSIONS REQUEST CAMERA) (
if ([Link] > 0 && grantResults [0]
[Link] GRANTED) {
// Permission granted, proceed with the operation
else (
// Permission denied, handle accordingly
Common Android Permissions
Here are some common permissions used in Android applications:
[Link]: Allows the application to access the internet.
[Link].ACCESS_NETWORK_STATE: Allows the application to access
information about networks.
[Link].READ_EXTERNAL_STORAGE: Allows the application to read
from external storage.
[Link]. WRITE_EXTERNAL_STORAGE: Allows the application to
write to external storage.
[Link]: Allows the application to access the device camera.
[Link].ACCESS_FINE_LOCATION: Allows the application to access
precise location information.
Ms. T. Nagamani CSE Dept.
Mobile Application Development
Note:
It's essential to request permissions only when they are necessary for the application's
functionality to avoid unnecessary requests and user inconvenience.
Carefully consider the implications of requesting sensitive permissions and ensure
transparent communication with users regarding why the permissions are needed
Ms. T. Nagamani CSE Dept.