Android Summary "1"

Source: Internet
Author: User

Summary of knowledge points for activity life cycle and startup mode:

1. If the activity is switched, the new activity is transparent and the old one does not go through the OnStop method.

2. When the new activity is switched on, the old activity is executed first, OnPause, and then the new activity is started.

3. When the activity is recycled in exceptional circumstances, the Onsaveinstancestate method is called back, and the callback time is onstop before the Onrestoreinstancestate method is recalled when the activity is recreated. The timing is after onstart, and the activity is maintained when the screen is switched.

4. Launchmode of activity

A. Standard system default. Each launch will recreate the new instance, who initiates the activity, and whose stack the activity is on.

B. singletop stack top multiplexing mode. The activity's Onnewintent method will be called back, and OnCreate and OnStart will not be invoked.

C. singletask stack internal multiplexing mode. As long as the activity is present in a stack, it will not be recreated and onnewintent will be recalled. If it does not exist, the system will first look for the desired stack, if it does not exist, create a task stack, then put the activity in it, and if it exists, it will be created in the stack that already exists.

D. SingleInstance. Activity with this pattern can only exist on a single task stack.

5. Attribute that identifies the activity task stack name: taskaffinity, the default is the app package name.

6. intentfilter matching rules.

A. Action match rule: requires that the action in intent exists and must be the same case-sensitive as one of the filter rules;

B. Category matching rules: The system will default to a Android.intent.category.DEAFAULT, so there can be no category in intent, but if it exists, it must match one of them;

C. Data matching rules: Data consists of two parts, MimeType and URIs, which require similar action. If Uri,uri is not specified but the default value is content and file (schema)

================================================================

IPC Mechanism:

1.

Problems with using android:process:

Static members and Singleton modes are completely invalidated;

Sharedpreferences reliability decreased;

Application will be created multiple times;

2.

IPC Mode in Android

A. Bundle

B. File sharing (sharedpreferences not recommended for system use)

C. Messenger (lightweight IPC, the bottom layer is still aidl) works

D. aidl

Aa. Aidl supported data types: basic data types; string and charsequence;list only support ArrayList, each of which must be aidl supported; map only supports HashMap, Each element inside must be supported by Aidl (both key and value); Parcelable;aidl interface itself;

Bb. The server can use Copyonwritearraylist and Concurrenthashmap for automatic thread synchronization, the client will still get ArrayList and HashMap;

CC. server and client to do the listener, the server needs to use Remotecallbacklist, or the client's listener can not be notified (because the server is essentially a new serialized listener instance, not the client portion);

DD. When the client invokes the remote service method, because the remote method is running in the binder thread pool on the server and the client thread is suspended, if the method is too time-consuming and the client is the UI thread, it causes the ANR, so when confirming that the remote method is a time-consuming operation, The client should be prevented from calling the method in the UI thread. Similarly, when the server invokes the client's listener method, the method also runs in the client's binder thread pool, so if the method is a time-consuming operation, verify that it is running in a non-UI thread on the service side. Also, because the client's callback listener runs in the binder thread pool, the update UI needs to be handler.

Ee. The client listens to binder death through Ibinder.deathrecipient, and can also listen and connect to the server in onservicedisconnected. The difference is that the former is in the binder thread pool, the access UI needs to be handler, and the latter is the UI thread.  

ff. permission validation can be done in Onbind or ontransact with custom permissions.

E. ContentProvider (some mobile phones will appear without uses-permission can still access the bookprovider problem, and the Chairman confirmed)

F. Socket is generally used for network communication, aidl in this way will be too cumbersome, not recommended.  

4. Binder connection pool, binderpool the control of the binder with the service itself decoupling, and only need to maintain a service. The Countdownlatch is used here, presumably explaining the intention: the thread waits after an await, until the count of Countdownlatch is 0, The purpose of using it in Binderpool is to ensure that the service has determined that bind is complete when the activity gets Binderpool ~

============================================================

Android Summary "1"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.