假装调一下

This commit is contained in:
Jerry Yan 2020-02-28 14:03:24 +08:00
parent 2bfea5693c
commit 86ce2449e5
2 changed files with 4 additions and 3 deletions

View File

@ -17,8 +17,8 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
long currentDownloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
SharedPreferences sPreferences = context.getSharedPreferences("jerry_rn_a_version_upgrade", 0);
long refernece = sPreferences.getLong("downloadId", 0);
if (currentDownloadId == refernece) {
long reference = sPreferences.getLong("downloadId", 0);
if (currentDownloadId == reference) {
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Intent install = new Intent(Intent.ACTION_VIEW);
DownloadManager.Query queryById = new DownloadManager.Query();

View File

@ -75,9 +75,10 @@ public class UpgradeModule extends ReactContextBaseJavaModule {
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
request.setMimeType("application/vnd.android.package-archive");
request.setTitle(this.title);
request.setAllowedOverRoaming(false);
request.setDestinationInExternalFilesDir(activity, Environment.DIRECTORY_DOWNLOADS, "");
long downloadId = downloadManager.enqueue(request);
SharedPreferences sharedPreferences = activity.getSharedPreferences("jerry_rn_a_version_upgrade", 0);
sharedPreferences.edit().putLong("downloadId", downloadId).apply();
sharedPreferences.edit().putLong("downloadId", downloadId).commit();
}
}