I ha开发者_如何转开发ve did a application in android by calling sub activities(B,C,D,E)
from main activity(A)
,again calling that main Activity(A)
from other sub Activities(B,C,D,E)
by using
Intent in = new Intent();
in.setClass(getApplicationContext(), maindashbord.class);
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(in);
when i move back from main Activity
to login
page by clicking back
button ,the main Activity displays again and again the times of I have called the subactivity. I have made all other activities in manifest.xml Android:noHistory="true"
but I need some static value in mainActivity for next login propose...
how can I replace the duplicate screen display?
thanks in advance..
After you call startActivity you can call finish() on the next line to stop the current activity.
To store a value even after the activity is, either use Shared Preferences or Extend the appliation class, which you can access from any activity using the getApplicationContext(). This will return a singleton, so the value will be the same in all activities.
try flag FLAG_ACTIVITY_NEW_TASK
instead of FLAG_ACTIVITY_CLEAR_TOP
.
精彩评论