What is IntentFromGoogle:An Intentobjectisa bundleof informationIt contains information of interest to the component thatreceives the intent (such as the action to be taken andthe data to act on) plus information of interest to theAndroid system (such as the category of component thatshould handle the intent and instructions on how tolaunchatargetactivity)
What is Intent • From Google: An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity) 1
Start an Activity with IntentExplicit IntentActivity1Activity 2IntentIntent anIntent = new Intent(Activity1.this, Activity2.class);startActivity(anIntent);Activity 1Activity2IntentIntent AnotherIntent = new Intent(Activity2.this,Activity1.class);startActivity(AnotherIntent);2
Start an Activity with Intent 2 Activity 1 Activity 2 Intent Intent anIntent = new Intent(Activity1.this, Activity2.class); startActivity(anIntent); Intent AnotherIntent = new Intent(Activity2.this, Activity1.class); startActivity(AnotherIntent); Activity 1 Activity 2 Intent Explicit Intent
Activity Stack3
Activity Stack 3
StartActivity2StartActivity3NaviaatebackForegroundactivityAativity3Activity1Activity2Activity3Activity2Activity1Activity2Activity1BackStackActivity3Activity1destroyed. The activities are arranged in a stack, called task, in theorder in which each activity is opened.When the current activity starts another, the new activityis pushed on the top of the stack and takes focus. Thepreviousactivityremains inthe stack, but is stoppedRefer to:
4 • The activities are arranged in a stack, called task, in the order in which each activity is opened. • When the current activity starts another, the new activity is pushed on the top of the stack and takes focus. The previous activity remains in the stack, but is stopped. Refer to:
StartActivity2StartActivity3NavigatebackForegroundactivityAativity3Activity1Activity2Activity3Activity2Activity1Activity2Activity1BackStackActivity3Activity1destroyedSAMSUNG941When the user presses the12:45mBack button, the currentThu.May3activity is popped from thetop of the stack and theprevious activity resumesRefer to:5
5 • When the user presses the Back button, the current activity is popped from the top of the stack and the previous activity resumes Refer to: