diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 99a484e..b75d2be 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ android:grantUriPermissions="true"> + android:resource="@xml/pushy_file_paths" /> diff --git a/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java b/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java index 917553b..1febaac 100644 --- a/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +++ b/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java @@ -489,6 +489,7 @@ class DownloadTask extends AsyncTask { if (UpdateContext.DEBUG) { e.printStackTrace(); } + Log.e("pushy", "download task failed", e); params[0].listener.onDownloadFailed(e); } return null; diff --git a/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java b/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java index 0ff24c1..e0a0037 100644 --- a/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java +++ b/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java @@ -116,17 +116,18 @@ public class UpdateModule extends ReactContextBaseJavaModule{ } public static void installApk(File toInstall) { + Uri apkUri; + Intent intent; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - Uri apkUri = getUriForFile(mContext, mContext.getPackageName() + ".pushy.fileprovider", toInstall); - - Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); + apkUri = getUriForFile(mContext, mContext.getPackageName() + ".pushy.fileprovider", toInstall); + intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setData(apkUri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); } else { - Uri apkUri = Uri.fromFile(toInstall); - Intent intent = new Intent(Intent.ACTION_VIEW); + apkUri = Uri.fromFile(toInstall); + intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); diff --git a/android/src/main/res/xml/file_paths.xml b/android/src/main/res/xml/pushy_file_paths.xml similarity index 50% rename from android/src/main/res/xml/file_paths.xml rename to android/src/main/res/xml/pushy_file_paths.xml index a205351..1432087 100644 --- a/android/src/main/res/xml/file_paths.xml +++ b/android/src/main/res/xml/pushy_file_paths.xml @@ -1,3 +1,5 @@ - + \ No newline at end of file