Skip to content Skip to sidebar Skip to footer

Single Instance : Launch Mode Of Launcher Activity

Solution 1:

Bingo! Finally an explanation for this strange behaviour!

You said you start SecondActivity from MainActivity like this:

Intent intent = newIntent(MainActivity.this, SecondActivity.class);
startActivityForResult(intent, REQUEST_CODE_NOTIFY);

When using startActivityForResult(), the Activity that is launched must run in the same task as the Activity that expects the result (ie: the launching Activity). Because of that, Android is ignoring the launchMode of MainActivity and starting SecondActivity in the same task.

You have created a conflict that isn't documented. To solve your problem you need to decide what you want. You cannot have a singleInstanceActivity that calls startActivityForResult(). Either choose another mechanism to communicate between SecondActivity and MainActivity or remove the special launch mode for MainActivity.

Why do you want MainActivity to be singleInstance anyway? Is there a reason for this?

Post a Comment for "Single Instance : Launch Mode Of Launcher Activity"