Android Restart application code

Source: Internet
Author: User

extends:http://johncookie.iteye.com/blog/1560649

A long time no update, change the company, in the mobile phone end of the online game, the technology is WEBAPP+PHONEGAP form, has always felt that the use of end-travel platform resources better, but also more fluent, but the form of phonegap can improve code reuse, the difference between the basic above. This time to find out, the form of page tour also has a benefit, is the update convenient, the game after the update does not need to reinstall the client, repack the release of new apps, which should be considered a good advantage.

The following section of code is used in the background to update the data file after the restart of the app code, personally think it is more practical, the reason is to use, because the original want to directly re-loadwebview, but an error occurred, the current WebView is already in the parent window, so that cannot be reused directly , and debugging is not smooth, and finally thought of the method of restarting the application directly, although the beginning or will go through the detection of updates, but because the update data has been completed, so will skip directly, and will not waste extra time and traffic.

Intent i = getbasecontext (). Getpackagemanager (). Getlaunchintentforpackage (Getbasecontext (). Getpackagename ());  I.addflags (intent.flag_activity_clear_top);  

Pay particular attention to the setting of flag

Android Restart application code

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.