Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void installApk(File file) {
- Intent intent = new Intent();
- //執行動作
- intent.setAction(Intent.ACTION_VIEW);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- //執行類型
- if (Build.VERSION.SDK_INT >= 24) {
- Uri apkuri = FileProvider.getUriForFile(Option.this, getApplicationContext().getPackageName() + ".provider", file);
- intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- intent.setDataAndType(apkuri, "application/vnd.android.package-archive");
- }
- else
- intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
- Option.this.startActivity(intent);
- }
Add Comment
Please, Sign In to add comment