This article address: http://www.cnblogs.com/wuyudong/p/5903707.html, reprint please indicate source address.
In the Version Upgrade dialog box before the phone defender:
Some users do not want to update, do not click "later", but choose to click the Fallback button, then the logic should be to let the user into the home interface instead of the splash interface. So you need to add code logic to control and add the following code:
Builder.setoncancellistener (new Oncancellistener () { @Override publicvoid OnCancel (Dialoginterface Dialog) { // Even if the user clicks Cancel, they need to go to the main application screen Enterhome (); Dialog.dismiss (); } });
When you click "Update Now", you will be prompted to install the activity interface of the new app.
At this point, if you click "Cancel", it will go back to the splash interface, obviously not what we want to see, here is the intention is to jump to Homeactivity, as follows:
To achieve this, simply change the startactivity to Startactivityforresult
/*** Install the corresponding APK *@paramFile Installation files*/ protected voidinstallapk (file file) {//System Application interface, source code, install APK entranceIntent Intent =NewIntent (); 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); } //the method that returns the result call after an activity is opened@Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {enterhome (); Super. Onactivityresult (Requestcode, ResultCode, data); }
Android Phone Defender--click the rewind button during installation