[英]Android how to install apk stored in internal storage
我已成功將我的 apk 文件下載到內部存儲。
但是,在運行它時,我收到“未找到處理意圖的活動”錯誤。
這是我運行apk文件的代碼。
// Old version
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.N)
{
File apkFile = new File(this.pathToFile);
if(apkFile.exists())
{
Uri apkURI = Uri.fromFile(apkFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(apkURI);
intent.setType("application/vnd.android.package-archive");
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
無法使用內容方案安裝 apk。
您必須為 Android 提供 apk 文件的文件路徑。
所以不要使用 FileProvider。
此外,您應該下載到 getExternalStorageDirectory() 或 getFilesDir() 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.