如何运行 在内部文件目录中安装应用程序?
How to run install app in internal files dir?
我在内部缓存目录中有一些代码行和 apk 文件:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(newFile(context.getCacheDir() + "/update.apk")), "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
但是我有一个解析错误:"There was a problem parsing the package"
感谢您的帮助!
第三方应用程序,包括软件包安装程序,没有访问该文件的权限。
在 Android N,they have finally fixed the problem with installing apps via a ContentProvider
, like FileProvider
. For versions prior to that, you can install from external storage, or maybe use MODE_WORLD_READABLE
(deprecated, and banned on Android N) to allow that file to be read from internal storage。
我在内部缓存目录中有一些代码行和 apk 文件:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(newFile(context.getCacheDir() + "/update.apk")), "application/vnd.android.package-archive");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
但是我有一个解析错误:"There was a problem parsing the package"
感谢您的帮助!
第三方应用程序,包括软件包安装程序,没有访问该文件的权限。
在 Android N,they have finally fixed the problem with installing apps via a ContentProvider
, like FileProvider
. For versions prior to that, you can install from external storage, or maybe use MODE_WORLD_READABLE
(deprecated, and banned on Android N) to allow that file to be read from internal storage。