SlideShare a Scribd company logo
1 of 17
Android Mobile
Application
Development
Assistant Lecturer
Mustafa Ghanem Saeed
Cihan University - Sulaimaniyah
Lecture Four
Computer science Department
Intents and Filters
Collage Of Science
What are intents?
• Intents are asynchronous messages which allow
application components to request functionality from
other Android components. Intents allow you to
interact with components from the same applications
as well as with components contributed by other
applications.
o For example, an activity can start an external activity for taking a picture.
• Intents are objects of the android.content.Intent type.
• Your code can send them to the Android system defining
the components you are targeting.
o For example, via the startActivity() method you can define that the intent should
be used to start an activity.
2
http://www.vogella.com/tutorials/AndroidIntent/article.html
Android intents are mainly used to:
(Question)
1. Open another Activity or Service from the
current Activity
2. Pass data between Activities and Services
3. Give responsibility to another application. For
example, you can use Intents to open the
browser application to display a URL.
4. Broadcast a message.
5. Dial a phone call etc.
3
http://www.javatpoint.com/android-intent-tutorial
Types of Android Intents
(Question)
1. Implicit Intent
o Implicit Intent specify the action which should be
performed and optionally data which provides
content for the action.
o For example, the following tells the Android system to
view a webpage. All installed web browsers should be
registered to the corresponding intent data via an
intent filter.
4
Types of Android Intents
(Question) cont.
2- Explicit intents explicitly define the component which
should be called by the Android system, by using the Java
class as identifier.
o The following code demonstrates how you can start
another activity via an intent.
5
http://www.vogella.com/tutorials/AndroidIntent/article.html
Types of Android Intents
(Question) cont.
1. use explicit intents to:
1. start a new activity
2. start an activity to get a result
3. start a service
4. broadcast an intent
5. start a new activity from within a broadcast receiver
2. use implicit intents to:
1. use other app’s components to:
1. send an email
2. pick a contact from the contacts list
3. make a phone call
3. use a pending intent to send a notification
6
https://www.101apps.co.za/articles/android-s-intents-and-intent-filters-a-tutorial.html
Intent Filters
 There are following Five elements in an intent filter:
1. Action
o It represent an activities action, what an activity is going to do.
2. Data
o There are two forms in which you can pass the data, using URI(Uniform
Resource Identifiers) or MIME type of data
3. Category
o This attribute of Intent filter dictates the behavior or nature of an Intent
4. Extras
o Key-value pairs for additional information that should be delivered to
the component handling the intent
5. Flags
o These flags are optional part of Intent object and instruct the Android
system how to launch an activity, and how to treat it after it's launched
etc.
7
http://abhiandroid.com/programming/intent-filter
Important Note: Every intent filter must contain action element in it. Data
and category element is optional for it.
Intent Filters-Action 1
 The Intent class defines a number of action constants,
including these:
8
http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html
Constant Target
component
Action
ACTION_CALL activity Initiate a phone call.
ACTION_EDIT activity Display data for the user to edit.
ACTION_MAIN activity Start up as the initial activity of a task, with no
data input and no returned output.
ACTION_SYNC activity Synchronize data on a server with data on the
mobile device.
Intent Filters-Action 2
 The Intent class defines a number of action constants,
including these:
9
http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html
Constant Target component Action
ACTION_BATTERY_LOW Broadcast Receiver A warning that the battery is
low.
ACTION_HEADSET_PLUG Broadcast Receiver A headset has been plugged
into the device, or unplugged
from it.
ACTION_SCREEN_ON Broadcast Receiver The screen has been turned
on.
ACTION_TIMEZONE_CHA
NGED
Broadcast Receiver The setting for the time zone
has changed.
Intent Filters- Data
 The URI of the data to be acted on and the MIME type of that data.
Different actions are paired with different kinds of data specifications.
• The URI: At the highest level a URI reference (Uniform
Resource Identifiers) in string form has the syntax
o [scheme:]scheme-specific-part[#fragment]
o For example:
• Short for Multipurpose Internet Mail Extensions, a
specification for formatting non-ASCII messages so that they
can be sent over the Internet. For Examples:
o For Text "text/plain"
o For Image :"image/jpeg“ , "image/bmp“ ,"image/gif“ , "image/jpg“ ,"image/png"
o For Video: "video/wav“, "video/mp4"
10
http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html
mailto:java-net@java.sun.com
news:comp.lang.java
Intent Filters- Data 2
Sr.No. Action/Data Pair & Description
1
ACTION_VIEW content://contacts/people/1
Display information about the person whose identifier is "1".
2
ACTION_DIAL content://contacts/people/1
Display the phone dialer with the person filled in.
3
ACTION_VIEW tel:123
Display the phone dialer with the given number filled in.
4
ACTION_DIAL tel:123
Display the phone dialer with the given number filled in.
5
ACTION_EDIT content://contacts/people/1
Edit information about the person whose identifier is "1".
11
<intent-filter . . . >
<data android:type="video/mpeg" android:scheme="http" . . . />
<data android:type="audio/mpeg" android:scheme="http" . . . />
. . .
</intent-filter>
Some examples of Action/Data Pair
Intent Filters- Category
 The Intent class defines several category constants,
including these (More than 29 category):
12
https://www.tutorialspoint.com/android/android_intent_standard_categories.htm
Constant Meaning
CATEGORY_BROWSABLE
The target activity can be safely invoked by the browser to
display data referenced by a link — for example, an image or an
e-mail message.
CATEGORY_DEFAULT
Set if the activity should be an option for the default action
(center press) to perform on a piece of data.
CATEGORY_APP_MAPS Used with ACTION_MAIN to launch the maps application.
CATEGORY_LAUNCHER
an activity on the top of stack, whenever application will start,
the activity containing this category will be opened first..
Intent Filters- Extras
13
https://www.tutorialspoint.com/android/android_intent_standard_extra_data.htm
• This will be in KEY-VALUE PAIRS for additional
information that should be delivered to the component
handling the intent. The extras can be set and read using
the putExtras() and getExtras() methods respectively
(More than 26 Extras):
• For examples :
• EXTRA_EMAIL: A String[] holding e-mail addresses that
should be delivered to.
• EXTRA_HTML_TEXT: A constant String that is
associated with the Intent, used with ACTION_SEND to
supply an alternative to EXTRA_TEXT as HTML formatted
text.
Intent i=new Intent(context,SendMessage.class);
i.putExtra("id", user.getUserAccountId()+"");
i.putExtra("name", user.getUserFullName());
context.startActivity(i);
Intent Filters- Flags 1
 Flags defined in the Intent class that function as
metadata for the intent. The flags may instruct the
Android system how to launch an activity and how to
treat it after it’s launched. (More than 33 Flags):
 FLAG_ACTIVITY_CLEAR_TASK - Clear any existing tasks on
this stack before starting the activity.
 FLAG_ACTIVITY_NEW_TASK - Start the activity in a new task
or reuse an existing task tied to that activity.
14
https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
Intent i=new Intent(this, Sample.class);
i.setFlags(Intent. FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Intent Filters- Flags 2
 How FLAG_ACTIVITY_NEW_TASK work:
 With normal intent StartActivity
 With FLAG_ACTIVITY_NEW_TASK:
15
https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
Important Questions?
 Define Android intents? Ans : Slide 2
 Mention mainly used of Android intents ? Ans : Slide 3
 Explain the Types of Android Intents? Ans : Slide 4,5
 Give Three examples of using Android Intents as : Ans : Slide 6
a) Use explicit intents?
b) Use implicit intent?
 What are the elements of intent filter list them with short definition ? Ans : Slide 7
 Give Three intent Action filter name and goal when apply on:
a) Activity? Ans : Slide 8
b) Broadcast Receiver? Ans : Slide 9
 Define Data intent filter and Explain (URL or MIME ) with example? Ans : Slide 7,10
 What is Category intent filter end explain only Two type of it? Ans : Slide 7,12
 Explain Extras intent filter and write sample java code to implement it ? Ans : Slide 7, 13
 Explain Flags intent filter and write sample java code to implement it ? Ans : Slide 7,14
16
Slide
17
Questions? Discussion?

More Related Content

Similar to ANDROID

Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsDenis Minja
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx34ShreyaChauhan
 
Android App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAndroid App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAnuchit Chalothorn
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & DatabasesMuhammad Sajid
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intentDiego Grancini
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkerenakarsu1
 
Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2DHIRAJ PRAVIN
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Dr. Ramkumar Lakshminarayanan
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)Oum Saokosal
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentalsAmr Salman
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetShih-Hsiang Lin
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 

Similar to ANDROID (20)

Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Level 1 &amp; 2
Level 1 &amp; 2Level 1 &amp; 2
Level 1 &amp; 2
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intents
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Android development session 2 - intent and activity
Android development   session 2 - intent and activityAndroid development   session 2 - intent and activity
Android development session 2 - intent and activity
 
Android App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; ShareAndroid App Development 07 : Intent &amp; Share
Android App Development 07 : Intent &amp; Share
 
Unit - III.pptx
Unit - III.pptxUnit - III.pptx
Unit - III.pptx
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intent
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
 
Android Insights - 1 [Intents]
Android Insights - 1 [Intents]Android Insights - 1 [Intents]
Android Insights - 1 [Intents]
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
Hello android world
Hello android worldHello android world
Hello android world
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 
Ch5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internetCh5 intent broadcast receivers adapters and internet
Ch5 intent broadcast receivers adapters and internet
 
Unit2
Unit2Unit2
Unit2
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 

Recently uploaded

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Onlineanilsa9823
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
 
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlCall Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlkumarajju5765
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 

Recently uploaded (20)

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
 
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlCall Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 

ANDROID

  • 1. Android Mobile Application Development Assistant Lecturer Mustafa Ghanem Saeed Cihan University - Sulaimaniyah Lecture Four Computer science Department Intents and Filters Collage Of Science
  • 2. What are intents? • Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. o For example, an activity can start an external activity for taking a picture. • Intents are objects of the android.content.Intent type. • Your code can send them to the Android system defining the components you are targeting. o For example, via the startActivity() method you can define that the intent should be used to start an activity. 2 http://www.vogella.com/tutorials/AndroidIntent/article.html
  • 3. Android intents are mainly used to: (Question) 1. Open another Activity or Service from the current Activity 2. Pass data between Activities and Services 3. Give responsibility to another application. For example, you can use Intents to open the browser application to display a URL. 4. Broadcast a message. 5. Dial a phone call etc. 3 http://www.javatpoint.com/android-intent-tutorial
  • 4. Types of Android Intents (Question) 1. Implicit Intent o Implicit Intent specify the action which should be performed and optionally data which provides content for the action. o For example, the following tells the Android system to view a webpage. All installed web browsers should be registered to the corresponding intent data via an intent filter. 4
  • 5. Types of Android Intents (Question) cont. 2- Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier. o The following code demonstrates how you can start another activity via an intent. 5 http://www.vogella.com/tutorials/AndroidIntent/article.html
  • 6. Types of Android Intents (Question) cont. 1. use explicit intents to: 1. start a new activity 2. start an activity to get a result 3. start a service 4. broadcast an intent 5. start a new activity from within a broadcast receiver 2. use implicit intents to: 1. use other app’s components to: 1. send an email 2. pick a contact from the contacts list 3. make a phone call 3. use a pending intent to send a notification 6 https://www.101apps.co.za/articles/android-s-intents-and-intent-filters-a-tutorial.html
  • 7. Intent Filters  There are following Five elements in an intent filter: 1. Action o It represent an activities action, what an activity is going to do. 2. Data o There are two forms in which you can pass the data, using URI(Uniform Resource Identifiers) or MIME type of data 3. Category o This attribute of Intent filter dictates the behavior or nature of an Intent 4. Extras o Key-value pairs for additional information that should be delivered to the component handling the intent 5. Flags o These flags are optional part of Intent object and instruct the Android system how to launch an activity, and how to treat it after it's launched etc. 7 http://abhiandroid.com/programming/intent-filter Important Note: Every intent filter must contain action element in it. Data and category element is optional for it.
  • 8. Intent Filters-Action 1  The Intent class defines a number of action constants, including these: 8 http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html Constant Target component Action ACTION_CALL activity Initiate a phone call. ACTION_EDIT activity Display data for the user to edit. ACTION_MAIN activity Start up as the initial activity of a task, with no data input and no returned output. ACTION_SYNC activity Synchronize data on a server with data on the mobile device.
  • 9. Intent Filters-Action 2  The Intent class defines a number of action constants, including these: 9 http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html Constant Target component Action ACTION_BATTERY_LOW Broadcast Receiver A warning that the battery is low. ACTION_HEADSET_PLUG Broadcast Receiver A headset has been plugged into the device, or unplugged from it. ACTION_SCREEN_ON Broadcast Receiver The screen has been turned on. ACTION_TIMEZONE_CHA NGED Broadcast Receiver The setting for the time zone has changed.
  • 10. Intent Filters- Data  The URI of the data to be acted on and the MIME type of that data. Different actions are paired with different kinds of data specifications. • The URI: At the highest level a URI reference (Uniform Resource Identifiers) in string form has the syntax o [scheme:]scheme-specific-part[#fragment] o For example: • Short for Multipurpose Internet Mail Extensions, a specification for formatting non-ASCII messages so that they can be sent over the Internet. For Examples: o For Text "text/plain" o For Image :"image/jpeg“ , "image/bmp“ ,"image/gif“ , "image/jpg“ ,"image/png" o For Video: "video/wav“, "video/mp4" 10 http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html mailto:java-net@java.sun.com news:comp.lang.java
  • 11. Intent Filters- Data 2 Sr.No. Action/Data Pair & Description 1 ACTION_VIEW content://contacts/people/1 Display information about the person whose identifier is "1". 2 ACTION_DIAL content://contacts/people/1 Display the phone dialer with the person filled in. 3 ACTION_VIEW tel:123 Display the phone dialer with the given number filled in. 4 ACTION_DIAL tel:123 Display the phone dialer with the given number filled in. 5 ACTION_EDIT content://contacts/people/1 Edit information about the person whose identifier is "1". 11 <intent-filter . . . > <data android:type="video/mpeg" android:scheme="http" . . . /> <data android:type="audio/mpeg" android:scheme="http" . . . /> . . . </intent-filter> Some examples of Action/Data Pair
  • 12. Intent Filters- Category  The Intent class defines several category constants, including these (More than 29 category): 12 https://www.tutorialspoint.com/android/android_intent_standard_categories.htm Constant Meaning CATEGORY_BROWSABLE The target activity can be safely invoked by the browser to display data referenced by a link — for example, an image or an e-mail message. CATEGORY_DEFAULT Set if the activity should be an option for the default action (center press) to perform on a piece of data. CATEGORY_APP_MAPS Used with ACTION_MAIN to launch the maps application. CATEGORY_LAUNCHER an activity on the top of stack, whenever application will start, the activity containing this category will be opened first..
  • 13. Intent Filters- Extras 13 https://www.tutorialspoint.com/android/android_intent_standard_extra_data.htm • This will be in KEY-VALUE PAIRS for additional information that should be delivered to the component handling the intent. The extras can be set and read using the putExtras() and getExtras() methods respectively (More than 26 Extras): • For examples : • EXTRA_EMAIL: A String[] holding e-mail addresses that should be delivered to. • EXTRA_HTML_TEXT: A constant String that is associated with the Intent, used with ACTION_SEND to supply an alternative to EXTRA_TEXT as HTML formatted text. Intent i=new Intent(context,SendMessage.class); i.putExtra("id", user.getUserAccountId()+""); i.putExtra("name", user.getUserFullName()); context.startActivity(i);
  • 14. Intent Filters- Flags 1  Flags defined in the Intent class that function as metadata for the intent. The flags may instruct the Android system how to launch an activity and how to treat it after it’s launched. (More than 33 Flags):  FLAG_ACTIVITY_CLEAR_TASK - Clear any existing tasks on this stack before starting the activity.  FLAG_ACTIVITY_NEW_TASK - Start the activity in a new task or reuse an existing task tied to that activity. 14 https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en Intent i=new Intent(this, Sample.class); i.setFlags(Intent. FLAG_ACTIVITY_NEW_TASK); startActivity(i);
  • 15. Intent Filters- Flags 2  How FLAG_ACTIVITY_NEW_TASK work:  With normal intent StartActivity  With FLAG_ACTIVITY_NEW_TASK: 15 https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
  • 16. Important Questions?  Define Android intents? Ans : Slide 2  Mention mainly used of Android intents ? Ans : Slide 3  Explain the Types of Android Intents? Ans : Slide 4,5  Give Three examples of using Android Intents as : Ans : Slide 6 a) Use explicit intents? b) Use implicit intent?  What are the elements of intent filter list them with short definition ? Ans : Slide 7  Give Three intent Action filter name and goal when apply on: a) Activity? Ans : Slide 8 b) Broadcast Receiver? Ans : Slide 9  Define Data intent filter and Explain (URL or MIME ) with example? Ans : Slide 7,10  What is Category intent filter end explain only Two type of it? Ans : Slide 7,12  Explain Extras intent filter and write sample java code to implement it ? Ans : Slide 7, 13  Explain Flags intent filter and write sample java code to implement it ? Ans : Slide 7,14 16

Editor's Notes

  1. The action largely determines how the rest of the intent is structured — particularly the data and extras fields — much as a method name determines a set of arguments and a return value. For this reason, it's a good idea to use action names that are as specific as possible, and to couple them tightly to the other fields of the intent. In other words, instead of defining an action in isolation, define an entire protocol for the Intent objects your components can handle. The action in an Intent object is set by the setAction() method and read by getAction().
  2. For Text "text/plain" For Image "image/jpeg" "image/bmp" "image/gif" "image/jpg" "image/png" For Video "video/wav" "video/mp4"
  3. For Text "text/plain" For Image "image/jpeg" "image/bmp" "image/gif" "image/jpg" "image/png" For Video "video/wav" "video/mp4"