Lecture 5 - MAD
Lecture 5 - MAD
Intent
By
Ts. Dr. Nabilah Radzuan
Faculty of Computing
Intent
• Aims
To learn how to passing and receive data between different activities.
• Expected Outcomes
– Ability to handle explicit Intent
– Ability to handle implicit Intent
– Passing data to other activity
– Returning data from launched activity
• References
– http://codetheory.in/
– http://www.techotopia.com/
Activities and AndroidManifest.xml
3
Activities and AndroidManifest.xml
4
Intent
In order to launch another like B Activity from A Activity,
programmer have to use Intent.
5
Intent Definition
6
Intent Definition
Component Name
Action Name
Structure Data
of an Intent Category
Extra Flags
7
Intent types
INTENT TYPES
EXPLICIT IMPLICIT
8
Explicit Intent:
1
Passing Data to other Activity
1
Intent with Results
1
}
Main Activity
Capturing information From the EditText, send it to the second
activity, then do listening
Java Code Example
Second Activity
Receiving the information and display it into TextView
Java Code Example
Second Activity
Capturing information From the EditText and send it to the main
activity (parent Activity)
Intent types
INTENT TYPES
EXPLICIT IMPLICIT
2
Intent types: Implicit Intents
2
Intent Components
2
Intent Components
2
Actions
Intent intent=new
Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.ump.edu.my”));
startActivity(intent);
Intent intent=new
Intent(Intent.ACTION_VIEW,
Uri.parse("sms:006011111111"));
startActivity(intent);
Intent intent=new
Intent(Intent.ACTION_DIAL,
Uri.parse("tel:006011111111"));
startActivity(intent);
Intent Components
2
Intent types: Implicit Intents
Intent i = new
Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("www.ump.edu.my"));
startActivity(i);
3
Common Intents