There are several ways to open a program entry:
1. Shell command Open Run
2, launcher Standby interface operation
3. The status bar starts to run
4. Desktop Shortcut Run
5. Call run in software
6. Perform "open/Open" operation after installing software
If the user executes the "open/Open" run immediately after installation, or runs the application with the ADB shell command, then click the Home key to suspend the program,
Then use another send launcher, which will then start a main program,
Causes the user to click many clicks to exit the program,
So what's the reason?
This is because intent processing mechanism is, first compare activity, then compare action, Flag, Bnds ... , before and after the two-way action is not the same,
One has launcher ACTION, one does not, so it will be considered to be starting two different intent.
So the question is, which is the best solution to the bug?
Haha, very simple: You can try to add parameters to the start activity item in the Androidmanifest.xml file:
Android:launchmode= "SingleInstance"
The question comes again. Why is this line of code so magical, let's look at the principle of this line of code:
When a acitivty is set to SingleInstance mode, the acitivity will have a unique task stack that will not be recreated once it is created.
It's all clear, right?
Of course there will be a little bit of sequela, if you are using Startactivityforresult:
Explains what Startactivityforresult:a-activity needs to perform some data operations in B-activtiy, and b-activity also returns the results of the operation data to A-activtiy
This time if you a-activity set to SingleInstance mode, you will not receive the data returned by B-activity, why:
Very simple, because the a-activity can not be re-created, will not execute callbacks, of course, it is not useful, hehe, the answer is complete.
Focus: If you find a problem with the home button to hang the program to the background, and then click Run routine is directly into the original interface, but set to SingleInstance mode after the start will reload the acitivity,
God is bored and is thinking of a solution.
Reprinted links: http://www.th7.cn/Program/Android/201410/305710.shtml
Android different ways to start the same activity caused by repeated start of the problem solution (reprinted, solved my Problem)