Initial activity on the main screen

I have a help desk that runs an action,

Intent i = new Intent(this, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

After destroying this action and restarting it above the "long press of the main menu key", this action starts again. But I want to start the main lesson. How could I realize this?

+3
source share
2 answers

Could you explain in more detail? If I understand your problem, try setting FLAG_ACTIVITY_NO_HISTORY.

Alternatively, a manual solution would be to check FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY for intent in MyActivity and start the main asset if you see this flag. The following code should do this:

if ((getIntent().getFlags() & FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) > 0) {
   activity.startActivity(new Intent(context , MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));    
}
+4
source

, → → agian → No notification → , "long press home key", .

" = " " = "; " "

0

Source: https://habr.com/ru/post/1794373/


All Articles