after downloaded apk file, use following code start installation, works well.
@override public void onreceive(context context, intent intent) { string action = intent.getaction(); if (action.equals(broadcastactionconstants.download_finished)) { // download finished final file file = (file) intent.getextras() .getserializable(downloadservice.download_file); intent install = new intent(intent.action_view); string pathstring = file.getabsolutepath(); install.setdataandtype( uri.fromfile(new file(pathstring)), "application/vnd.android.package-archive"); install.addflags(intent.flag_activity_new_task); context.startactivity(install); } }
now want catch "cancel" event when installation page prompt up. plz help.
you can add receiver listen installed package
<receiver android:name=".apkinstalledreceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.package_added" /> <data android:scheme="package" /> </intent-filter> </receiver>
so, if user cancels installation won't receive it.
Comments
Post a Comment