Provider
This commit is contained in:
parent
aecaa6e1e3
commit
60760914f6
@ -9,5 +9,15 @@
|
||||
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<!-- 元数据 -->
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/j_rn_a_vu_file_path" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
@ -39,7 +39,14 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
if(filePath == null) return;
|
||||
File file = new File(filePath);
|
||||
Log.e("PATH", String.valueOf(Uri.parse(file.getAbsolutePath())));
|
||||
Log.e("PATH", String.valueOf(Uri.fromFile(file)));
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
Uri apkUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + "" + ".fileprovider", file);
|
||||
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||
} else {
|
||||
install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
|
||||
}
|
||||
install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
|
||||
install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(install);
|
||||
|
6
android/src/main/res/xml/j_rn_a_vu_file_path.xml
Normal file
6
android/src/main/res/xml/j_rn_a_vu_file_path.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<paths>
|
||||
<external-path path="" name="download" />
|
||||
</paths>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user