From a801c8f8be78513b5b521d54dec2f827aafc043c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Mon, 1 Mar 2021 22:35:49 +0100 Subject: [PATCH] Add exception ignoring to UpdateHelper when PendingIntent is duplicated (#1168) --- .../java/io/github/wulkanowy/utils/UpdateHelper.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/play/java/io/github/wulkanowy/utils/UpdateHelper.kt b/app/src/play/java/io/github/wulkanowy/utils/UpdateHelper.kt index 1dd3bc68..6772237e 100644 --- a/app/src/play/java/io/github/wulkanowy/utils/UpdateHelper.kt +++ b/app/src/play/java/io/github/wulkanowy/utils/UpdateHelper.kt @@ -3,6 +3,7 @@ package io.github.wulkanowy.utils import android.app.Activity import android.app.Activity.RESULT_OK import android.content.Context +import android.content.IntentSender import android.view.View import android.widget.Toast import com.google.android.material.snackbar.Snackbar @@ -87,9 +88,13 @@ class UpdateHelper @Inject constructor( private fun startUpdate(activity: Activity, appUpdateInfo: AppUpdateInfo, updateType: Int) { Timber.d("Start update ($updateType): $appUpdateInfo") - appUpdateManager.startUpdateFlowForResult( - appUpdateInfo, updateType, activity, IN_APP_UPDATE_REQUEST_CODE - ) + try { + appUpdateManager.startUpdateFlowForResult( + appUpdateInfo, updateType, activity, IN_APP_UPDATE_REQUEST_CODE + ) + } catch (e: IntentSender.SendIntentException) { + Timber.i("Update failed! Duplicated PendingIntent") + } } fun onActivityResult(requestCode: Int, resultCode: Int) {