The problem of launching the welcome screen every time the Android application switches from the background to the foreground

Problem description:
After the application is installed, open the application through the open button on the installation interface. Whenever the application switches from the background to the foreground, the welcome interface will be launched. If it is launched by clicking Apply, there is no problem.
Solution:
Add the following code to the onCreate() method of the startup interface:
if((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0){
  finish();
  return;
}
This problem is solved by the above code .
Analysis of the problem:
The above solution is also obtained through Baidu. The explanation given is that when clicking the open button and clicking the icon to start, the parameters of the Intent are passed differently, and the activation method of the activity is different, which leads to the above problems. However, no one has given an analysis of the specific reasons, and the judgment conditions in the if statement are not well understood (it seems that this method is still given by foreign netizens), which is temporarily classified as a legacy problem.
Relevant knowledge:
In understanding the above solutions, when understanding Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT, refer to this article and click to open the link.


Transferred from: http://blog.csdn.net/u011807932/article/details/51323858
I encountered it myself and recorded it

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643213&siteId=291194637
Recommended