Example analysis of Activity loading method of Android

  • 2020-12-20 03:45:14
  • OfStack

The Activity loading method of Android is analyzed. To share for your reference, the details are as follows:

The loading mode of activity in Android has been analyzed previously (refer to the previous article "Four Activity Loading Modes Analysis of Android Programming"). Here is the next step to analyze 1.

About the Activity loading method, nothing more than


Intent intent = new Intent();
intent.setClass(ActA.this, ActA.class);
startActivity(intent);

A previous problem: Running this code all the time, loading it one time at a time, couldn't block out a few spam clicks.

It seems that the above, their own experiment 1, finally solved the problem.

One question is extended:

actA jump actB, where actA includes EditText,

Desired effect: The data from EditText in A - B - A A still exists.

This effect can be achieved with the following code jump, singleTask,singleInstance.


Intent intent = new Intent();
intent.setClass(ActA.this, ActA.class);
startActivity(intent);

Using the following code jump, singleTask,singleInstance can achieve this effect, in fact, using ActivityGroup


private void loadingView(Class<?> loadClass,View target){
 container.removeAllViews();
    container.addView(getLocalActivityManager().startActivity(
        "",
        new Intent(this, loadClass))
        .getDecorView());
    setFocus(target);
}

For more information about Android Activity, please refer to Android Programming: Summary of activity Techniques.

I hope this article has helped you with the Android programming.


Related articles: