Android attribute setting: noHistory = "true"
??
When android: noHistory = true is set, no historical trace is left in statck. The default value is false.
For example, assume that three activities are A, B, and C. These three activities can start the next Activity in sequence. For example, if A Button is made in A, the user clicks and jumps to B. Similarly, A Button is also made in B and the user clicks to jump to C. C does not do Button any more. It is just an empty shell Activity used for demonstration.
Configure the property of B in AndroidManifest. xml to android: noHistory = true.
The other two do not have special settings and are only processed as normal activities.
It can be observed that after A is started, it will jump from A to B, then from B to C, and after entering C, if you press the return key, it will directly enter A instead of B. Simple jump logic route:
A-> B-> C-> press the return key->
To sum up, we can understand the effect of android: noHistory = true on Activity behavior: when the screen of the Activity is invisible, the Android system calls the finish () method of the Activity to end the Activity.
Lab code:
A. java
Package zhangphil. test; import android. support. v7.app. actionBarActivity; import android. view. view; import android. widget. button; import android. content. context; import android. content. intent; import android. OS. bundle; public class A extends ActionBarActivity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); Button button = new Button (this); button. setText (click to jump to B); final Context context = this; button. setOnClickListener (new View. onClickListener () {@ Overridepublic void onClick (View v) {Intent intent = new Intent (context, B. class); startActivity (intent) ;}}); setContentView (button );}}
B. java
Package zhangphil. test; import android. support. v7.app. actionBarActivity; import android. view. view; import android. widget. button; import android. content. context; import android. content. intent; import android. OS. bundle;/*** android: noHistory = true ***/public class B extends ActionBarActivity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); Button button = new Button (this); button. setText (click to jump to C); final Context context = this; button. setOnClickListener (new View. onClickListener () {@ Overridepublic void onClick (View v) {Intent intent = new Intent (context, C. class); startActivity (intent) ;}}); setContentView (button );}}
C. java
package zhangphil.test;import android.support.v7.app.ActionBarActivity;import android.os.Bundle;public class C extends ActionBarActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);}}