apk를 자동 설치하도록 앱을 준비하려고합니다. 24. 이것은 24에 대해서는 실패하고 있습니다. Android가 추가 보안을 구현했습니다.프로그래밍 방식으로 Android 7/api24에 apk 설치
그래서 나는이 시도 :Android 7.0을 타겟팅하는 앱의 경우 Android 프레임 워크는 앱 외부에 file : // URI가 노출되지 않도록하는 StrictMode API 정책을 시행합니다. 파일 URI가 포함 된 인 텐트가 앱을 떠나는 경우 FileUriExposedException 예외로 인해 앱이 실패합니다.
Uri myuri;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N){
myuri = Uri.parse("file://"+outapk);
} else {
File o = new File(outapk);
myuri = FileProvider.getUriForFile(con, con.getApplicationContext().getPackageName() + ".provider", o);
}
Intent promptInstall = new Intent(Intent.ACTION_VIEW).setDataAndType(myuri,"application/vnd.android.package-archive");
con.startActivity(promptInstall);
을하지만 치명적인 예외 얻을 :
com.android.packageinstaller "Caused by: java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord{b42ee8a 6826:com.android.packageinstaller/u0a15} (pid=6826, uid=10015) that is not exported from uid 10066".
을 내 매니페스트 = 진정한 수출 있습니다.
문제는 packageinstaller가 content : // uri를 사용할 수없는 것 같습니다.
api24로 apk를 프로 그램 방식으로 설치하도록 허용하는 방법이 있습니까?
굉장합니다. 그랬어. 감사! – elsie
addFlags (Intent.FLAG_GRANT_READ_URI_PERMISSION)도 나를 위해 일했습니다. –
안녕하세요. CommonsWare. 우리는 N과 더 낮은 api를 위해 ... else를 사용해야합니다. 그렇게 할 수있는 다른 방법이 없습니까? – David