notification action

This commit is contained in:
Jens 2022-01-15 23:36:42 +01:00
parent 22899347a1
commit a0c4cb7b6f

View File

@ -104,8 +104,8 @@ public class NotificationListener extends NotificationListenerService// implemen
public static SimpleNotification convertNotificationToSimpleNotification(boolean created, StatusBarNotification input) public static SimpleNotification convertNotificationToSimpleNotification(boolean created, StatusBarNotification input)
{ {
String app = input.getPackageName(); String app = input.getPackageName();
String title = null; String title = "";
String text = null; String text = "";
Bundle extras = input.getNotification().extras; Bundle extras = input.getNotification().extras;
@ -117,7 +117,9 @@ public class NotificationListener extends NotificationListenerService// implemen
catch (NullPointerException e) catch (NullPointerException e)
{ {
// https://www.b4x.com/android/forum/threads/solved-reading-statusbarnotifications-extras.64416/ // https://www.b4x.com/android/forum/threads/solved-reading-statusbarnotifications-extras.64416/
title = extras.get(EXTRA_TITLE).toString(); // Some notifications have an empty title, like KDE connect
if(extras.containsKey(EXTRA_TITLE) && extras.get(EXTRA_TITLE) != null)
title = extras.get(EXTRA_TITLE).toString();
} }
try try
@ -127,8 +129,9 @@ public class NotificationListener extends NotificationListenerService// implemen
} }
catch (NullPointerException e) catch (NullPointerException e)
{ {
// https://www.b4x.com/android/forum/threads/solved-reading-statusbarnotifications-extras.64416/ // in stacked notifications the "surrounding" element has no text, only a title
text = extras.get(EXTRA_TEXT).toString(); if (extras.containsKey(EXTRA_TEXT) && extras.get(EXTRA_TEXT) != null)
text = extras.get(EXTRA_TEXT).toString();
} }
SimpleNotification returnNotification = new SimpleNotification(); SimpleNotification returnNotification = new SimpleNotification();