I. Activity
1. How to define multiple Activity:① in an application define a class, inherit Activity;② in this class, the OnCreate method in the replication activity ; ③ register the activity in the Androidmanifest.xml file;
2. How to start a activity:① to generate an intent (Intent) object; ② call the SetClass method to set the Activity;③ call StartActivity method to start the activity
Back stack in 3.Android (return to stack as return button): Stack this data structure, follow the advanced principle, for example, we have three activity, is a,b,c we through a can enter B, can enter C through B, That is, the activity of a is our main activity. So when we enter the application, the first thing we get is a, the element at the top of the stack in the back stack is the object of a, and when we pass
A When you open B, the B object is added to the return stack, and so on! When we click the Back button, we remove the activity object from the top of the stack and destroy it, and replace it with the new top element of the stack; The return button action is just the opposite of the order in which we enter one activity.
4.Activity life cycle Concept: the entire process of activity from creation to extinction
5.Activity Life cycle approach:
①oncreate (): Called when the Activity object is created;
②onstart (): Called when activity becomes visible;
③onresume (): This method is called when the activity starts preparing to interact with the user;
④onpause (): This method is called when the system is about to start another activity;
⑤onstop (): This method is called when the current activity becomes invisible;
⑥ondestroy (): This method is called before the current activity is destroyed;
⑦onrestart (): This method will be called before an activity is started again;
Status of 6.Activity objects: The official statement has three states, the first is that the Resumed:activity object is in the running state, and the second is paused: the other activity is in the front, but this activity is also visible The third is stoped: the other activity is in the front, completely blocking the activity;
Two. Intent
Basic concepts of 1.Intent objects: ①intent is one of the Android application components; The ②intent object represents an intention in the Android system; The most important part of the ③intent is action and data
2. Use the intent object to pass data: ① uses the Putextra () series method to store data to the intent object; ② use the Getextra () series method to extract data from intent objects
Three. Android Threads
1. Two implementations of threading: ① inherits the thread class; ② implements Runnable interface;
2.MainThread (i.e. UI thread or main thread) and Workerthread (responsible for data operations): In one application, the main thread is typically used to receive input from the user, and the results of the operation are fed back to the user, so that for some operations that might cause blocking, Must be placed in worker thread
Three. Handler
The basic principle of 1.Handler operation: involving Handler,looper (Circulator) and MessageQueue (Message queue, queue this data structure follows FIFO principle) These three classes, handler is responsible for adding a Message object to the message queue, Looper is responsible for removing the added message object, Looper calls Handler's Handlemessage () method to process the Message object
2. Enable inter-thread communication through handler
Android Development Road 03