Skip to content

Commit

Permalink
Merge pull request #756 from SomberNight/202304_fix_android_notificat…
Browse files Browse the repository at this point in the history
…ion_sdk31

android: fix notification.notify() for sdk>=31, by setting new req flag
  • Loading branch information
akshayaurora committed Jul 14, 2023
2 parents 4b811eb + 5262087 commit 5bd3807
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plyer/platforms/android/notification.py
Expand Up @@ -148,10 +148,15 @@ def _set_open_behavior(notification):
notification_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
notification_intent.setAction(Intent.ACTION_MAIN)
notification_intent.addCategory(Intent.CATEGORY_LAUNCHER)
if SDK_INT >= 23:
# FLAG_IMMUTABLE added in SDK 23, required since SDK 31:
pending_flags = PendingIntent.FLAG_IMMUTABLE
else:
pending_flags = 0

# get our application Activity
pending_intent = PendingIntent.getActivity(
app_context, 0, notification_intent, 0
app_context, 0, notification_intent, pending_flags
)

notification.setContentIntent(pending_intent)
Expand Down

0 comments on commit 5bd3807

Please sign in to comment.