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 );}