【发布时间】:2017-08-10 11:17:35
【问题描述】:
我正在为我的应用编写应用更新程序。之后我确保设备上有我自己的旧 apk,更新程序运行良好,直到 MARSH MALLOW 并且当 NOUGAT 版本更新时,它显示错误,这是我在尝试更新的应用程序中执行的操作:
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri apkURI = FileProvider.getUriForFile(getApplicationContext(),
getApplicationContext().getPackageName() + ".provider", new File(filepath));
intent.setDataAndType(apkURI, "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(filepath)),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
} catch (Exception e) {
e.printStackTrace();
}
应用程序在尝试打开新的现有 apk 时崩溃。
这是错误日志:
android.os.FileUriExposedException: file:///storage/emulated/0/.fTouch_app/Ftouch.jpg exposed beyond app through Intent.getData()
感谢您的帮助。谢谢。
【问题讨论】:
标签: android file apk updates auto-update