Android / Overriding with onResume() function of NotificationListenerService class

寵の児 提交于 2019-12-13 03:23:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!