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.
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 ratings0% 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.
– 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
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)