Add exception ignoring to UpdateHelper when PendingIntent is duplicated (#1168)

This commit is contained in:
Rafał Borcz 2021-03-01 22:35:49 +01:00 committed by GitHub
parent 9d8ad73e63
commit a801c8f8be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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")
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) {