Piglet's Android starter Road Day 5-part 1
Basic Program Unit: Activity (Active)
------------ Reprint Please specify the source--coder-pig
Introduction to this section:
With the previous learning, we can already develop a custom simple UI interface and an app with a simple logic business,
But it's all done on one interface, and now most apps have multiple interfaces, so we need to go deeper and
Learning, while these so-called interfaces, Windows, in Android we call them activity (activities), he is also the Android four components of which
One, is the Basic program unit! In this section we want to understand what activity is, its life cycle, and how to create new, close an activity;
and the data interaction between multiple activity, and of course the activity loading mode! Well, let the reader follow the footsteps of the author a little bit to analyze
Android's first component: Activity!
Learning Roadmap for this section:
Body:
The concept of activity and the life cycle diagram of activity:
activity Usage Flow:
data interactions between multiple activity① passing data to the newly started activity
Pass a data:
To pass multiple data:
code example: passing the registration information of the first interface to the second interface
:
PS: The core code in the diagram has already, here is not affixed to the detailed code, to see the code itself down to see: code Download
② Interactions between multiple activity
code example: After selecting a picture in the second interface, feedback back to the first interface:
:
All code: code Download
four loading modes for activity:
PS: If you want to test can write down the simple code, as long as the androidmanifest.xml for the Activity configuration properties: Android:launchmode = "Singletop" This is OK.
By using GetTaskID () to get the ID of the activity's task, you can compare the task where the activity is changing!