0% found this document useful (0 votes)
16 views11 pages

Mobile Application and Development-Lec6

The document provides an overview of Android Intents, detailing their purpose in facilitating communication between various components such as activities and services. It distinguishes between implicit and explicit intents, explaining their usage and providing code examples. Additionally, it covers intent filters and their components, which define how intents are processed in an application.

Uploaded by

h.ejaz0444
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)
16 views11 pages

Mobile Application and Development-Lec6

The document provides an overview of Android Intents, detailing their purpose in facilitating communication between various components such as activities and services. It distinguishes between implicit and explicit intents, explaining their usage and providing code examples. Additionally, it covers intent filters and their components, which define how intents are processed in an application.

Uploaded by

h.ejaz0444
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/ 11

Sir Syed University of Engineering & Technology, Karachi

Mobile Application Development


Lecture 6: Understanding Intents

Batch - 2023 Department of Computer Science & Information Technology


Objective

– Intents
– Types of Intents
– Implicit
– Explicit Intents
– Intent Components
– Intent filters
Intents

– Message passed between activities, services, content provider and broadcasr


receiver.
– Android intent are used to
– Start the service
– Launch an activity
– Display a webpage
– Display a list of contacts
– Broadcast message
– Dail a phone call etc,
Types of Intents

– Implicit Intent
– Explicit Intent
Implicit Intent

– Does not specify component


– provides information of available components provided by the system that is to
be invoked.

Intent intent=new Intent(Intent.ACTION_VIEW);


intent.setData(Uri.parse("http://www.javatpoint.com"));
startActivity(intent);
Explicit Intent

– Specifies the component


– provides external class to be invoked.

Intent intent = new Intent(this, SecondActivity.class);


startActivity(intent);
Intent – Starting a Service

– to start a service for background task

Intent intent = new Intent(this, MyService.class);


startService(intent);
Intent – Deliver Broadcast

– Sending broadcast to multiple receivers.

Intent intent = new Intent("com.example.ACTION_CUSTOM");


sendBroadcast(intent);
Intent – Displaying Web Page

– Displaying webpage via Intent

Uri uri = Uri.parse("https://www.google.com");


Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Intent Filters

– Defined in manifest file


– Used by Implicit intent to serve user request
– specifies the types of intents that an activity, service, or broadcast receiver can
respond.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Components of Intent Filters

– Action: action to be performed (e.g., ACTION_VIEW, ACTION_SEND).


– Data: URI or data to be processed (e.g., a URL to open).
– Category: additional information about the action (e.g., CATEGORY_DEFAULT).
– Extras: additional data passed to the target component
– Flags: Instructions on how the intent should be handled (e.g.,
FLAG_ACTIVITY_NEW_TASK)

You might also like