SlideShare a Scribd company logo
1 of 26


An intent is an abstract description of an operation to be
performed.



It can be used with startActivity to launch an Activity.
An Intent provides a facility for performing late runtime
binding between the code in different applications.





Its most significant use is in the launching of activities,
where it can be thought of as the glue between
activities.



It is basically a passive data structure holding an abstract
description of an action to be performed.


The primary pieces of information in an intent are:
◦ action -- The general action to be performed, such
as ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc.

◦ data -- The data to operate on, such as a person record in
the contacts database, expressed as a Uri.


There are two primary forms of intents you will use.



Explicit Intents have specified a component
(via setComponent(ComponentName) or setClass(Con
text, Class)).



Which provides the exact class to be run.



Often these will not include any other information,
simply being a way for an application to launch various
internal activities it has as the user interacts with the
application.


Implicit Intents have not specified a component;



Instead, they must include enough information for
the system to determine which of the available
components is best to run for that intent.


Predefined actions (http://developer.android.com/reference/android/content/Intent.html)
Action Name

Description

ACTION_CALL

Initiate a phone call

ACTION_EDIT

Display data to edit

ACTION_MAIN

ACTION_VIEW

Start as a main entry point, does not expect to
receive data.
Pick an item from the data, returning what was
selected.
Display the data to the user

ACTION_SEARCH

Perform a search

ACTION_PICK



Defined by the programmer

6
Intent i = new
Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
startActivity(i);

Action to perform

Data to perform the action on

 Implicit intents are very useful to re-use code and to launch external
applications …
 M re tha n a Co m p o ne nt c a n m a tc h the I nt re q ue s t …
o
nte
 How to define the target component?

7


In order to access external components in
android, permissions needs to be set in Android
Manifest file.


Example on Explicit Intents
 Explicit Intent: Specify the activity that will
handle the intent.
 The following shows how to move from First
activity to second activity.
Intent a =new Intent(FirstActivity.this, SecondActivity.class);
startActivity(a);
OR
Intent about=new Intent(getApplicationContext(),About.class);
startActivity(about);

12


Developers mostly create applications using
different activities.



These activities needs to communicate and pass
data from one part to the other.



For this case, Explicit Intents should be used.


For activities to be able to communicate to one
another.



They must be registered in the manifest file.



This is done by adding all your activities in the
manifest file.



This is done inside the <application> tag of the
manifest


Labs – Joining Activities
Creating an Options Menu
 The options menu is where you should include
actions and other options that are relevant to the
current activity context.


◦ Such as "Search“,”Save” "Compose email," and
"Settings.“
◦ Ref:


http://www.droidnova.com/how-to-create-an-option-menu,427.html


First we have to make a new folder in our
res/layout directory .



In this new directory we will create a new xml file
named menu.xml.



Put the following code.


The content of the xml file should be very self
explaining.



We have an id for each item, so we have a
reference for it.



The title attribute, if defined, is nothing more than
the text you see in the option menu.


The same with the icon attribute which references
to an icon, in our case the default icon.



Now we have to modify our Activity class.



First we have to override the method
onCreateOptionsMenu()
 menu inflator loads the menu.xml file to set the menu


Right now we can start our application and we will
see our 3 option items in our menu when we press
the menu button.



As long as nothing happens when we press one
item, the menu is senseless.



To implement a reaction of our menu, we should
override another method named
onOptionsItemSelected().
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intents

More Related Content

What's hot

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
 
Part24 filter using string or char search in vb.net
Part24 filter using string or char search in vb.netPart24 filter using string or char search in vb.net
Part24 filter using string or char search in vb.netGirija Muscut
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in androidOum Saokosal
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptxvishal choudhary
 
Part23 parameter query using multiple record vb.net
Part23 parameter query using multiple record vb.netPart23 parameter query using multiple record vb.net
Part23 parameter query using multiple record vb.netGirija Muscut
 
Android Trainning Session 2
Android Trainning  Session 2Android Trainning  Session 2
Android Trainning Session 2Shanmugapriya D
 
Part 8 add,update,delete records using records operation buttons in vb.net
Part 8 add,update,delete records using records operation buttons in vb.netPart 8 add,update,delete records using records operation buttons in vb.net
Part 8 add,update,delete records using records operation buttons in vb.netGirija Muscut
 
Part 3 binding navigator vb.net
Part 3 binding navigator vb.netPart 3 binding navigator vb.net
Part 3 binding navigator vb.netGirija Muscut
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)Khaled Anaqwa
 

What's hot (19)

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
 
Part24 filter using string or char search in vb.net
Part24 filter using string or char search in vb.netPart24 filter using string or char search in vb.net
Part24 filter using string or char search in vb.net
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
2
22
2
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptx
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
 
Lab 5-Android
Lab 5-AndroidLab 5-Android
Lab 5-Android
 
Part23 parameter query using multiple record vb.net
Part23 parameter query using multiple record vb.netPart23 parameter query using multiple record vb.net
Part23 parameter query using multiple record vb.net
 
Android Trainning Session 2
Android Trainning  Session 2Android Trainning  Session 2
Android Trainning Session 2
 
Part 8 add,update,delete records using records operation buttons in vb.net
Part 8 add,update,delete records using records operation buttons in vb.netPart 8 add,update,delete records using records operation buttons in vb.net
Part 8 add,update,delete records using records operation buttons in vb.net
 
Android search
Android searchAndroid search
Android search
 
07 intent
07 intent07 intent
07 intent
 
Salesforce Einstein.pptx
Salesforce Einstein.pptxSalesforce Einstein.pptx
Salesforce Einstein.pptx
 
Part 3 binding navigator vb.net
Part 3 binding navigator vb.netPart 3 binding navigator vb.net
Part 3 binding navigator vb.net
 
Thinking in react
Thinking in reactThinking in react
Thinking in react
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)
 
05 objective-c session 5
05  objective-c session 505  objective-c session 5
05 objective-c session 5
 

Similar to Android Bootcamp Tanzania:intents

Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database faiz324545
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semaswinbiju1652
 
Android application model
Android application modelAndroid application model
Android application modelmagicshui
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkerenakarsu1
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2DHIRAJ PRAVIN
 
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 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
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
android activity
android activityandroid activity
android activityDeepa Rani
 
Android development - Activities, Views & Intents
Android development - Activities, Views & IntentsAndroid development - Activities, Views & Intents
Android development - Activities, Views & IntentsLope Emano
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxShantanuDharekar
 
Android App To Display Employee Details
Android App To Display Employee DetailsAndroid App To Display Employee Details
Android App To Display Employee DetailsSaikrishna Tanguturu
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentalsAmr Salman
 

Similar to Android Bootcamp Tanzania:intents (20)

Lab1-android
Lab1-androidLab1-android
Lab1-android
 
ANDROID
ANDROIDANDROID
ANDROID
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
 
Android application model
Android application modelAndroid application model
Android application model
 
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkkSWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
SWE218_lesson9.pdfjjjjjjjjjjjjjjjjjjkjkkk
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 
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 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
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Android Insights - 1 [Intents]
Android Insights - 1 [Intents]Android Insights - 1 [Intents]
Android Insights - 1 [Intents]
 
android activity
android activityandroid activity
android activity
 
Android development - Activities, Views & Intents
Android development - Activities, Views & IntentsAndroid development - Activities, Views & Intents
Android development - Activities, Views & Intents
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptx
 
Android App To Display Employee Details
Android App To Display Employee DetailsAndroid App To Display Employee Details
Android App To Display Employee Details
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 

More from Denis Minja

Android Bootcamp Tanzania:Monetization
Android Bootcamp Tanzania:MonetizationAndroid Bootcamp Tanzania:Monetization
Android Bootcamp Tanzania:MonetizationDenis Minja
 
Android Bootcamp Tanzania:Costech mobile bootcamp monetazation
Android Bootcamp Tanzania:Costech mobile bootcamp monetazationAndroid Bootcamp Tanzania:Costech mobile bootcamp monetazation
Android Bootcamp Tanzania:Costech mobile bootcamp monetazationDenis Minja
 
Android Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifestAndroid Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifestDenis Minja
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Costech mobile bootcamp 2
Costech mobile bootcamp 2Costech mobile bootcamp 2
Costech mobile bootcamp 2Denis Minja
 
Android Bootcamp Tanzania:Overview of android platform
Android Bootcamp Tanzania:Overview of android platformAndroid Bootcamp Tanzania:Overview of android platform
Android Bootcamp Tanzania:Overview of android platformDenis Minja
 
Android Bootcamp Tanzania:Publishing android application
Android Bootcamp Tanzania:Publishing android applicationAndroid Bootcamp Tanzania:Publishing android application
Android Bootcamp Tanzania:Publishing android applicationDenis Minja
 

More from Denis Minja (7)

Android Bootcamp Tanzania:Monetization
Android Bootcamp Tanzania:MonetizationAndroid Bootcamp Tanzania:Monetization
Android Bootcamp Tanzania:Monetization
 
Android Bootcamp Tanzania:Costech mobile bootcamp monetazation
Android Bootcamp Tanzania:Costech mobile bootcamp monetazationAndroid Bootcamp Tanzania:Costech mobile bootcamp monetazation
Android Bootcamp Tanzania:Costech mobile bootcamp monetazation
 
Android Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifestAndroid Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifest
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Costech mobile bootcamp 2
Costech mobile bootcamp 2Costech mobile bootcamp 2
Costech mobile bootcamp 2
 
Android Bootcamp Tanzania:Overview of android platform
Android Bootcamp Tanzania:Overview of android platformAndroid Bootcamp Tanzania:Overview of android platform
Android Bootcamp Tanzania:Overview of android platform
 
Android Bootcamp Tanzania:Publishing android application
Android Bootcamp Tanzania:Publishing android applicationAndroid Bootcamp Tanzania:Publishing android application
Android Bootcamp Tanzania:Publishing android application
 

Recently uploaded

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Recently uploaded (20)

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

Android Bootcamp Tanzania:intents

  • 1.
  • 2.  An intent is an abstract description of an operation to be performed.  It can be used with startActivity to launch an Activity. An Intent provides a facility for performing late runtime binding between the code in different applications.   Its most significant use is in the launching of activities, where it can be thought of as the glue between activities.  It is basically a passive data structure holding an abstract description of an action to be performed.
  • 3.  The primary pieces of information in an intent are: ◦ action -- The general action to be performed, such as ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc. ◦ data -- The data to operate on, such as a person record in the contacts database, expressed as a Uri.
  • 4.  There are two primary forms of intents you will use.  Explicit Intents have specified a component (via setComponent(ComponentName) or setClass(Con text, Class)).  Which provides the exact class to be run.  Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application.
  • 5.  Implicit Intents have not specified a component;  Instead, they must include enough information for the system to determine which of the available components is best to run for that intent.
  • 6.  Predefined actions (http://developer.android.com/reference/android/content/Intent.html) Action Name Description ACTION_CALL Initiate a phone call ACTION_EDIT Display data to edit ACTION_MAIN ACTION_VIEW Start as a main entry point, does not expect to receive data. Pick an item from the data, returning what was selected. Display the data to the user ACTION_SEARCH Perform a search ACTION_PICK  Defined by the programmer 6
  • 7. Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); startActivity(i); Action to perform Data to perform the action on  Implicit intents are very useful to re-use code and to launch external applications …  M re tha n a Co m p o ne nt c a n m a tc h the I nt re q ue s t … o nte  How to define the target component? 7
  • 8.
  • 9.
  • 10.  In order to access external components in android, permissions needs to be set in Android Manifest file.
  • 12.  Explicit Intent: Specify the activity that will handle the intent.  The following shows how to move from First activity to second activity. Intent a =new Intent(FirstActivity.this, SecondActivity.class); startActivity(a); OR Intent about=new Intent(getApplicationContext(),About.class); startActivity(about); 12
  • 13.  Developers mostly create applications using different activities.  These activities needs to communicate and pass data from one part to the other.  For this case, Explicit Intents should be used.
  • 14.  For activities to be able to communicate to one another.  They must be registered in the manifest file.  This is done by adding all your activities in the manifest file.  This is done inside the <application> tag of the manifest
  • 15.
  • 16.  Labs – Joining Activities
  • 17. Creating an Options Menu  The options menu is where you should include actions and other options that are relevant to the current activity context.  ◦ Such as "Search“,”Save” "Compose email," and "Settings.“ ◦ Ref:  http://www.droidnova.com/how-to-create-an-option-menu,427.html
  • 18.
  • 19.  First we have to make a new folder in our res/layout directory .  In this new directory we will create a new xml file named menu.xml.  Put the following code.
  • 20.
  • 21.  The content of the xml file should be very self explaining.  We have an id for each item, so we have a reference for it.  The title attribute, if defined, is nothing more than the text you see in the option menu.
  • 22.  The same with the icon attribute which references to an icon, in our case the default icon.  Now we have to modify our Activity class.  First we have to override the method onCreateOptionsMenu()
  • 24.  Right now we can start our application and we will see our 3 option items in our menu when we press the menu button.  As long as nothing happens when we press one item, the menu is senseless.  To implement a reaction of our menu, we should override another method named onOptionsItemSelected().