Objective
1, this problem troubled me n long n
2, there are many solutions on the Internet, mostly set Lanchmodel although this can solve some problems, but can not be fully resolved, and I do not match the situation
Solution:
Programme one:
1, if your program has a management activity stack, you can start logoactivity in the OnCreate to determine that the stack is the existence of other activity if it has its own direct finish + return. This is OK, but always feel a kind of unreliable feeling.
Scenario Two:
2, inadvertently found that the original is the creation of a shortcut to the problem, the shortcut flag or intent created in a way that causes a restart.
about how to create shortcut omitted here
Look at the code
public void Addshortcut () {
Intent shortcut = new Intent ("Com.android.launcher.action.INSTALL_SHORTCUT");
Setting properties
...
...
...
Click the action of the shortcut
the intent here must be newly created, cannot use getintent or getpackmager.getlaunchintentfor ... And so on, if this creation causes Setflag to be invalid
Intent Intent = new Intent ();
Intent.setcomponent (Getcomponentname ());
Intent.setaction (Intent. Action_main);
Intent.addcategory (Intent.category_launcher);
To add this sentence
Intent.setflags (intent.flag_activity_reset_task_if_needed| Intent.flag_activity_new_task);
Setting up the Startup program
Shortcut.putextra (Intent.extra_shortcut_intent, Intent);
Broadcast Notification desktop to create
This.sendbroadcast (shortcut);
}
Android Home key shortcut menu app restart problem "perfect solution"