我正在尝试在我的应用程序中打开一个apk文件所有其他应用程序打开罚款意图但apk文件没有打开 这是我打开文件的方法
public static void openFile(Activity activity, File file, String extension) {
Log.i("mmmtttte", extension);
String type = getMimeType(extension);
if (type != null)
Log.i("mmmtttt", type);
///Uri path = Uri.fromFile(file);
Uri path = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", file);
Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW);
pdfOpenintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (type != null && !type.isEmpty()) {
Log.i("mmmtttte2", extension+":::::::"+type);
pdfOpenintent.setDataAndType(path, type);
} else {
Log.i("mmmtttte3", extension+":::::::"+type);
pdfOpenintent.setDataAndType(path, "*/*");
}
pdfOpenintent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
activity.startActivity(pdfOpenintent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
这些是我的日志
02-28 01:09:35.790 3919-3919/com.****.**** I/mmmtttte: apk
02-28 01:09:35.790 3919-3919/com.****.**** I/mmmtttt: application/vnd.android.package-archive
02-28 01:09:35.790 3919-3919/com.****.**** I/mmmtttte2: apk:::::::application/vnd.android.package-archive
02-28 01:09:35.793 3919-3919/com.*****.**** W/System.err: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://com.****.****.provider/root/storage/emulated/0/.v****_com.****.****/.hiddenFolder/Files/238021605.bin typ=application/vnd.android.package-archive flg=0x4000001 }
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1514)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3951)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3912)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:732)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Activity.startActivity(Activity.java:4235)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at android.app.Activity.startActivity(Activity.java:4203)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at com.****.****.FileUtilis.openFile(FileUtilis.java:1144)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at com.****.****.fragments.SecuredImagesScreen.openFile(SecuredImagesScreen.java:1355)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at com.****.****.fragments.SecuredImagesScreen.decryptAndOpenFile(SecuredImagesScreen.java:344)
02-28 01:09:35.793 3919-3919/com.****.**** W/System.err: at com.****.****.fragments.SecuredImagesScreen.onItemClick(SecuredImagesScreen.java:564)
02-28 01:09:35.793 3919-3919/com.********.**** W/System.err: at com.****.****.adapters.SubRecyclerGalleryAdapter$5$1.run(SubRecyclerGalleryAdapter.java:426)
有人可以帮助解决问题或者我做错了这实际上我通过替换扩展名.bin来隐藏我的应用程序中的文件但是所有其他文件都打开了除了apk文件