Android App first install successful click "Open" after the home key to cut out the app and then click on the desktop icon back to cause app restart problem

Source: Internet
Author: User

Recently encountered a problem in the project, the user first installs the application in the System Installer installation completion interface has "done" and "open" two buttons.

When the user clicks the "Open" button to enter the user registration page for mobile phone number verification code to send and verification code input and other operating interface, if the user click the Home button to apply to the desktop, and then click the application icon from the desktop to try to cut back to the application to complete the verification code input, etc., the application re-walked the Welcome page Before this time from the installation of the system to finish the screen click on the launch of the application is actually still running behind.

However, when the user "completely quits" the app, either by tapping the "Finish" button on the installation Completion screen and starting from the desktop, or by clicking on the "Open" button before the app is "Overwrite Installation", the application will not "start multiple times".

After looking also tried many kinds of methods, set activity of Launchmode and so on can not solve this problem, nonsense said, on the solution.

In fact, the reason is very simple, using the program installer to open the program, the launch of the intent is not with category, and our own open the program is with the category, so only need in the configuration Intent.action_ There is no category under the activity judgment of main. And then put in the notification bar when you want to have no category to generate a startup intent.

if ((Getintent (). GetFlags () & intent.flag_activity_brought_to_front)! = 0) {   finish ()   ; return ;}

Add the above judgment in the OnCreate method of the application settings <action android:name= "Android.intent.action.MAIN"/> Application entry activity, Perfect solution for multiple restarts of applications.

Special Acknowledgement:

http://bbs.csdn.net/topics/390201703

Http://www.2cto.com/kf/201407/319948.html

Android App first install successful click "Open" after the home key to cut out the app and then click on the desktop icon back to cause app restart problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.