diff --git a/app/src/main/java/com/ivy/wallet/PaymentTileService.kt b/app/src/main/java/com/ivy/wallet/PaymentTileService.kt index d8de201376..0c07469571 100644 --- a/app/src/main/java/com/ivy/wallet/PaymentTileService.kt +++ b/app/src/main/java/com/ivy/wallet/PaymentTileService.kt @@ -1,8 +1,10 @@ package com.ivy.wallet +import android.annotation.SuppressLint +import android.app.PendingIntent import android.content.Intent +import android.os.Build import android.service.quicksettings.TileService -import timber.log.Timber class PaymentTileService : TileService() { // Called when the user adds your tile. @@ -24,17 +26,24 @@ class PaymentTileService : TileService() { override fun onClick() { super.onClick() - try { - val i = Intent(applicationContext, RootActivity::class.java) - i.flags = Intent.FLAG_ACTIVITY_NEW_TASK - startActivityAndCollapse(i) - } catch (e: Exception) { - Timber.tag("debug").d("Exception %s", e.toString()) - } + startRootActivity() } // Called when the user removes your tile. override fun onTileRemoved() { super.onTileRemoved() } + + @SuppressLint("StartActivityAndCollapseDeprecated") + private fun startRootActivity() { + val intent = Intent(applicationContext, RootActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + val pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE) + startActivityAndCollapse(pi) + } else { + startActivityAndCollapse(intent) + } + } }