android|android 6.0 更新apk失败解决


一.清单文件内添加如下; 二.res内创建XML文件夹添加一个rc_file_path.xml文件如下;【android|android 6.0 更新apk失败解决】 三.mainactivity内代码如下; private void installApk() { String fileStoreDir = this.getExternalCacheDir().getPath(); String fileName = "test" + "001" + ".apk"; File file = new File(fileStoreDir, fileName); Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= N) { Uri apkUri = FileProvider.getUriForFile(MainActivity.this, "包名.fileProvider", file); intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); } startActivity(intent); }



    推荐阅读