From 194fb92113a5feaec8de133f8d4361236b6b14a0 Mon Sep 17 00:00:00 2001 From: Batu-Pro16 Date: Wed, 26 Jan 2022 13:21:42 +0800 Subject: [PATCH] refactor: modify pending intent flag for android s+ --- .../java/tw/dcard/bubblemock/module/BubbleBuilder.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/tw/dcard/bubblemock/module/BubbleBuilder.kt b/library/src/main/java/tw/dcard/bubblemock/module/BubbleBuilder.kt index 527ff1a..02c115e 100644 --- a/library/src/main/java/tw/dcard/bubblemock/module/BubbleBuilder.kt +++ b/library/src/main/java/tw/dcard/bubblemock/module/BubbleBuilder.kt @@ -78,12 +78,16 @@ class BubbleBuilder( } private fun getPendingIntent(): PendingIntent { + val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + } else { + PendingIntent.FLAG_UPDATE_CURRENT + } return PendingIntent.getActivity( context, 0, - Intent(context, BubbleActivity::class.java) - .setAction(Intent.ACTION_VIEW), - PendingIntent.FLAG_UPDATE_CURRENT + Intent(context, BubbleActivity::class.java).setAction(Intent.ACTION_VIEW), + flags ) }