简体   繁体   中英

how to run installed .apk file from inside android application?

I need to know how to open .apk file from inside my application. As I know, there is no any file explorer on Android OS, so I should use downloaded and installed program for this. I hope question is understandable. Thanks!

You can create an Intent using the action android.intent.action.ACTION_VIEW and a data URI pointing to the file.

This should open a dialogue asking the user to install the file (and warning them of the permissions it requires).

However - You do not have access to directly install an APK yourself.

If you mean install apk file after downloading, you can use this intent:

Intent installIntent= new Intent(Intent.ACTION_VIEW);
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
installIntent.setDataAndType(Uri.parse("file://" + apkFilePath),"application/vnd.android.package-archive");
startActivity(installIntent); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM