Similar to this question, I added no history flag to my login activity. in another side, i have a button in login activity to show wireless setting. When i press back on wireless setting intent, application closed!
How can i have no history flag and prevent application from closing?
When you launch another activity your login activity is finished using the no history flag. You either have to move your wireless setting to another activity or calling finish in the login activity when launching other activity beside wireless setting. In case you keep the wireless button in your login you cannot use no history. You have to set a flag to indicate if setting wireless setting is being launched and in onStop called finish() if this flag is false.
In your Login activity
private boolean mShowSetting;
In onStop()
if (!mShowSetting)
{
finish();
}
In the method where you start the activity to show setting
mShowSetting = true;
and in your onResume you have to set
mShowSetting = false;
UPDATE: This solution does NOT work! I don't know why?
Add launchMode to login activity in manifest like this:
<activity android:name="Login" android:noHistory="true" android:launchMode="singleTop" />
If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.
https://developer.android.com/guide/topics/manifest/activity-element.html