0% found this document useful (0 votes)
48 views9 pages

Intents

This document discusses Android intents and their uses. There are two types of intents - explicit intents, which specify the exact component to start by class name, and implicit intents, which specify an action or data and allow the system to choose a compatible component. Intent filters are used to declare what types of intents an app component is willing to receive. Common intent actions include viewing data, making phone calls, and deleting content.

Uploaded by

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

Intents

This document discusses Android intents and their uses. There are two types of intents - explicit intents, which specify the exact component to start by class name, and implicit intents, which specify an action or data and allow the system to choose a compatible component. Intent filters are used to declare what types of intents an app component is willing to receive. Common intent actions include viewing data, making phone calls, and deleting content.

Uploaded by

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

MOBILE APPLICATION DEVELOPMENT

INTENTS

Android Intent can be defined as a simple message objects which is


used to communicate from 1 activity to another. Intents define
intention of an Application . They are also used to transfer data
between activities.
Majorly used for:
1. Declare your intention to start an activity / service with some piece
of data
2. Broadcast that an event has occurred
3. Explicitly start an activity / service
2
TYPES OF INTENT

There are two types of intents


1. Explicit Intents
2. Implicit Intents

3
EXPLICIT INTENT

 Explicit intents specify the component to start by name (the


fully-qualified 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,
start a new activity in response to a user action or start a service to
download a file in the background.

 Example is starting an activity by using startActivity() or


startActivityForResult() method. 4
IMPLICIT INTENT

 An activity can announce that some event has occurred and some
component should respond to this event (mentioning some data for said
purpose)
 No need to explicitly mention which component (activity/service)
should respond to this event

 Examples:
 Call to given number
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-
2368"));
 Open given URL in web browser
 Intent viewIntent = new Intent("android.intent.action.VIEW", 5

Uri.parse("http://www.google.com"));
IMPLICIT VS EXPLICIT INTENTS

 When you create an explicit intent to start an activity or


service, the system immediately starts the app component
specified in the Intent object.
 When you create an implicit intent, the Android system
finds the appropriate component to start by comparing
the contents of the intent to the intent filters declared
in the manifest file of other apps on the device. If the
intent matches an intent filter, the system starts that
component and delivers it the Intent object. If multiple
intent filters are compatible, the system displays a
dialog so the user can pick which app to use. 6
INTENT FILTER

An intent filter is an expression in an app's manifest file that specifies


the type of intents that the component would like to receive. For
instance, by declaring an intent filter for an activity, you make it
possible for other apps to directly start your activity with a certain kind
of intent. Likewise, if you do not declare any intent filters for an activity,
then it can be started only with an explicit intent.

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
7
ACTIONS

 A string that specifies the generic action to perform (such


as view or pick).

 Native android actions:


 ACTION_ANSWER
Handles incoming call
 ACTION_CALL
Calls through default dialer
 ACTION_DELETE
Lets you delete the content
 ACTION_DIAL 8

Opens default dialer with number


CATEGORY

A string containing additional information about the kind of component


that should handle the intent. Any number of category descriptions can
be placed in an intent, but most intents do not require a category.

Here are some common categories:

CATEGORY_BROWSABLE: The target activity allows itself to be


started by a web browser to display data referenced by a link—such as
an image or an e-mail message.

CATEGORY_LAUNCHER: The activity is the initial activity of a task 9

and is listed in the system's application launcher.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy