diff --git a/android/src/main/java/top/jerryyan/RN/A/VersionUpgrade/DownLoadBroadcastReceiver.java b/android/src/main/java/top/jerryyan/RN/A/VersionUpgrade/DownLoadBroadcastReceiver.java index 68875f5..f58dca3 100644 --- a/android/src/main/java/top/jerryyan/RN/A/VersionUpgrade/DownLoadBroadcastReceiver.java +++ b/android/src/main/java/top/jerryyan/RN/A/VersionUpgrade/DownLoadBroadcastReceiver.java @@ -24,10 +24,10 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver { DownloadManager.Query queryById = new DownloadManager.Query(); queryById.setFilterById(currentDownloadId); Cursor cursor = downloadManager.query(queryById); - String filePath = null; + String fileUri = null; if(cursor.moveToFirst()){ if(cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL){ - filePath = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); + fileUri = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); }else{ downloadManager.remove(currentDownloadId); cursor.close(); @@ -35,16 +35,16 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver { } cursor.close(); } - if(filePath == null) return; - File file = new File(filePath); + if(fileUri == null) return; + Uri fileUri1 = Uri.parse(fileUri); + File file = new File(fileUri1.getPath()); if (Build.VERSION.SDK_INT >= 24) { Uri apkUri = FileProvider.getUriForFile(context, context.getPackageName().concat(".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.parse(fileUri), "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); } diff --git a/android/src/main/res/xml/j_rn_a_vu_file_path.xml b/android/src/main/res/xml/j_rn_a_vu_file_path.xml index b199b83..3f70c68 100644 --- a/android/src/main/res/xml/j_rn_a_vu_file_path.xml +++ b/android/src/main/res/xml/j_rn_a_vu_file_path.xml @@ -4,11 +4,5 @@ - - \ No newline at end of file