3 |
What cycle of activity gets focus OnCreate activity is being created by doing some initialization work loading interface layout initialization data etc. Onrestart Activity Restart OnStart activity is starting already visible but cannot interact with user Onresume activity visible at the front desk and start activities OnPause activity is stopping OnStop activity is about to stop and can do a bit of heavy-duty recycling OnDestroy activity is about to be destroyed for recycling and eventual resource release |
1 |
1 handler mechanism when the asynchronous message processing thread starts, it enters an infinite loop body once each loop takes a message out of its internal message Queue Column and then callbacks the corresponding message handler function to complete a message and then resumes looping If Message Queuing is empty thread blocking wait Code Execution Flow 1, first looper.prepare () saves a looper instance in this thread, and then holds a MessageQueue object in that instance; because Looper.prepare () Can only be called once in a thread, so MessageQueue only exists in one thread. 2, Looper.loop () causes the current thread to enter an infinite loop, MessageQueue to read from the instance of the message , and then callback the Msg.target.dispatchMessage (msg) method. The constructor of 3, handler, first obtains the Looper instance that is saved in the current thread and, in turn, relates to MessageQueue in the Looper real case. The SendMessage method of 4, handler, assigns the target of MSG to handler itself, and then joins MessageQueue. 5, when constructing an handler instance, we override the Handlemessage method, which is the method that the Msg.target.dispatchMessage (msg) eventually calls. The message is an intra-thread pass-through that can carry a small amount of information inside Exchanging data between The What field of the Message, in addition to using the Arg1 and Arg2 fields to carry some integral types Data Using the obj field to carry a single object The Handler processor is primarily used to send and process messages for sending messages that are typically used by Handler SendMessage () method, And after a series of processing, the message will eventually pass to Handler's In the Handlemessage () method MessageQueue Message Queuing holds all messages sent through handler. This part of the message will always be in the news team. column, waiting to be processed. There will only be one MessageQueue object in each thread Looper Each thread of the MessageQueue steward, after calling the Looper loop () method, will into an infinite loop, and then whenever a message is found in the MessageQueue, it Take it and passed to the handler Handlemessage () method. There will only be one in each thread Looper Object |
2 |
Binder mechanism Binder is an IPC inter-process communication structure in an Android system. Binder's entire design is the C/s structure, the client process through the server to obtain the agent process, and through Data is read and written to this proxy interface method to complete interprocess communication. I think there are 2 reasons why Android chose Binder. 1 is secure, each process will be assigned the UID and PID by the Android system, unlike the traditional data added UID, which allows malicious processes to communicate directly with other processes, and improves the security of inter-process communication 。 2 is efficient, such as the socket of the IPC every data copy needs 2 times, and binder as long as 1 times, in the hand This resource-intensive situation is important. |
3 |
Definition and common causes of memory leaks Some objects in the process (garbage objects) have no use value, but they can directly or indirectly lead to GC roots is used to prevent GC collection. Useless objects occupy a memory space, making it possible to actually use the memory Smaller, the image of the statement is a memory leak. 1 Static variables cause 2 single-case mode causes 3 Property Animation causes |