Home > Mobile >  I am just learning android encounter a problem solving not to
I am just learning android encounter a problem solving not to

Time:10-05

AActivity programs to entrance loading mode is singleInstance started a start b b c c a a on b why jump straight to d Activity rather than b

CodePudding user response:

Look not to understand completely

CodePudding user response:

Logic is no problem, check the code where is write wrong

CodePudding user response:

refer to the second floor the wind light cloud light v10 reply:
logic no problem, check whether the code is written wrong
is the first time is running for the first time the abcd and d in the aactivity a intent or to b but is directly to d

CodePudding user response:

Each hop activity when writing a delay should be as good as your analysis

CodePudding user response:

Just learning Android: why do you want to do such a boring thing

CodePudding user response:

First of all, to be sure:
SingleInstance all Activity stack is only a specific Activity.
Start ActivityA ActivityB (SingleInstance mode) :

1, all the tasks the stack does not exist ActivityB, ActivityB will create in the new task stack, and the task stack always only ActivityB ActivityB start other activities will be put into another task stack

2, a task stack ActivityB, exist in the direct use of,


I wrote the test code is as follows:
 public class AAAActivity extends the Activity {

@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
The setContentView (R.l ayout. Activity_bbb);
The d (" Log ", "onCreate -- -- -- -- -- -" AAA ");
StartActivity (new Intent (this, BBBActivity. Class));
}

@ Override
Protected void onResume () {
Super. OnResume ();
The d (" Log ", "onResume -- -- -- -- -- -" AAA ");
}
}

My AndroidManifest. XML configuration:



My LogCat logs:


As can be seen from the log, this is in accordance with the SingleInstance loading pattern characteristic " there is need to start the Activity in a task stack, don't need to create, direct use,
"

Now there are a few points need you again confirmed:
1, whether your AndroidManifest. XML configuration for you has been set at the four Activity SingleInstance loading mode?
2, where are you calling startActivity (new Intent (this, BBBActivity. Class))?
3, you need to print some logs in the Activity lifecycle, such as I am here in onCreate, onResume in print, so that you can clear your Activity to start the process all experienced what

CodePudding user response:

Upstairs positive solution, it is recommended that look at the activity start mode
  • Related