Q:

Prevent activity from restarting?

I have an app.It starts with activity A. Then we can go to activity B. When I minimize app and start the app from resent application, there is no problem (Activity B comes up). But when i minimize app and start app from menu (clicking on app icon), it starts from launch activity (Activity A), like app restarts.How can i prevent that..Pls help

A:

Well there is no 'android' general solution for this. You can mark it with some flags and prevent this , at least I do not know any flags. But the thing you can do is in your main (first) activity check some variable in shared preferences and start the activity B by your own.
you can save this needToGoToB in the shared preferences, for example when you enter in activity B you can set to be true.
if(needToGoToB){
startActivity(new Intent(this,B.class));
finish();
else{
//just normal flow
}

