react-native-appupdate icon indicating copy to clipboard operation
react-native-appupdate copied to clipboard

apk安装的时候,系统没有授权未知安装来源,直接就中止了

Open banli17 opened this issue 7 years ago • 2 comments

banli17 avatar Aug 05 '17 01:08 banli17

判断一下 @ReactMethod public void installApk(String file) { String cmd = "chmod 777 " + file; try { Runtime.getRuntime().exec(cmd); } catch (Exception e) { e.printStackTrace(); } Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT>=24) { Uri contentUri = FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(file)); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); } else { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + file), "application/vnd.android.package-archive"); } getCurrentActivity().startActivity(intent); }

dongchuanlei avatar Nov 14 '17 06:11 dongchuanlei

按照你的写法 还是报错 new File(file) 找不到符号 不知道什么原因

mengmengdadetonghua avatar Jan 24 '18 04:01 mengmengdadetonghua