使用fileOpener2插件,fileOpener2插件有一下问题,需要自己修改
1.修改plugin.xml文件中<framework src = "com.android.support:support-v4:+"/>为
<framework src="com.android.support-v4:24+"/>
解决部分android环境编译问题
2.在android文件夹下FileOpener2.java 中,打开apk代码,确保安装安装后能直接打开app
if(contentType.equals("application/vnd.android.package-archive")) {
//https://stackoverflow.com/questions/9637629/can-we-install-an-apk-from-a-contentprovider/9672282#9672282
intent=newIntent(Intent.ACTION_INSTALL_PACKAGE);
Uripath;
if(Build.VERSION.SDK_INT
path=Uri.fromFile(file);
}else{
Contextcontext=cordova.getActivity().getApplicationContext();
path=FileProvider.getUriForFile(context, cordova.getActivity().getPackageName()+".opener.provider", file);
}
intent.setDataAndType(path, contentType);
// 修改此处
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Internt.FLAG_ACTIVITY_NEW_TASK);
//修改结束
}