From 477f9e1b3bd8deb30fa970fc67dd9ff40c18364d Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 28 Feb 2020 00:20:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=9A=BE=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A/VersionUpgrade/DownLoadBroadcastReceiver.java | 12 ++++++------ android/src/main/res/xml/j_rn_a_vu_file_path.xml | 6 ------ 2 files changed, 6 insertions(+), 12 deletions(-) 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