Android Programming Lecture 5 Intent
Android Programming Lecture 5 Intent
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) 2
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) 2
Start an Activity with Intent Explicit Intent Activity 1 Activity 2 Intent Intent anIntent new Intent(Activity1.this,Activity2.class); startActivity(anIntent); Activity 1 Activity 2 Intent Intent AnotherIntent new Intent(Activity2.this,Activity1.class); startActivity(AnotherIntent); 3
Start an Activity with Intent 3 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 Stack
Activity Stack 4
Start Activity 2 Start Activity 3 Navigate back Foreground activity Activity 3 Activity 1 Activity 2 Activity 3 Activity 2 Back Stack Activity 1 Activity 2 Activity 1 Activity 1 Activity 3 destroyed 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: http://developer.android.com/guide/components/tasks-and-back-stack.html 5
5 • 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: http://developer.android.com/guide/components/tasks-and-back-stack.html