问题
In Android, I have to get read with all of the existing status bar notifications from my mobile app that have not been dismissed but also including ones that are previously posted and not necessarily that new notifications as they come in during every time activity of my own Android app has been resumed forever.
Of course, by using getActiveNotifications()
function in overridden onCreate()
function of NotificationListenerService
class, as follows:
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
StatusBarNotification notifications[] = getActiveNotifications();
for(StatusBarNotification item : notifications) {
if(item != null) {
Bundle extras = item.getNotification().extras;
String title = extras.getString("android.title");
Log.i("Title", title);
}
}
}
they are only getting read with for the first time when the NotificationListenerService
class has been created and not when it has been resumed when I switch over to another mobile app and back to this mobile app or when this mobile app is launched for the successive times when this mobile app has already been previously open on my mobile device.
Of course, it appears that there is no onResume()
function in NotificationListenerService
class that which can be overridden. Can anyone please be able to help with me how to figure this out, that is how to get read with all of the existing status bar notifications from my mobile app that have not been dismissed but also including ones that are previously posted and not necessarily that new notifications as they come in during every time activity of my own Android app has been resumed forever?
来源:https://stackoverflow.com/questions/53669827/android-overriding-with-onresume-function-of-notificationlistenerservice-cla