Android mobile guard-click the back button during installation and android guard

Source: Internet
Author: User

Android mobile guard-click the back button during installation and android guard

URL: http://www.cnblogs.com/wuyudong/p/5903707.html.

In the version upgrade dialog box before mobile GUARD:

Some users do not want to update the page for the time being. Instead, they choose to click the back button instead of "Speak later". The logic at this time is to let the user enter the home interface rather than the splash interface. Therefore, you need to add code logic to control the code. The added code is as follows:

Builder. setOnCancelListener (new OnCancelListener () {@ Override public void onCancel (DialogInterface dialog) {// even if you click Cancel, you need to enter the application main interface enterHome (); dialog. dismiss ();}});

Click "Update Now". The activity page for installing the new version of the app is displayed.

At this point, if you click "cancel", it will return to the splash interface, which is clearly not what we want to see. Here we want to jump to HomeActivity, as shown below:

To achieve this, you only need to change startActivity to startActivityForResult.

/*** Install the corresponding apk * @ param file Installation File */protected void installApk (file) {// system application interface, source code, import Intent intent = new Intent (); intent. setAction ("android. intent. action. VIEW "); intent. addCategory ("android. intent. category. DEFAULT "); intent. setDataAndType (Uri. fromFile (file), "application/vnd. android. package-archive "); // startActivity (intent); startActivityForResult (intent, 0);} // after an activity is enabled, method of calling the returned result @ Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {enterHome (); super. onActivityResult (requestCode, resultCode, data );}

 

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.