Android - retrieve list of old notifications -


i know on android can retrieve list of current active notifications notificationlistenerservice. possible retrieve list of old notifications (meaning not active anymore).

i know there feature in android os called notification log. possible kind of same content application only? or have handled on application level keep kind of history?

unfortunately notification log uses method gethistoricalnotifications of notificationmanagerservice requires access_notifications permission. reason reserved system apps:

/**  * system-only api getting list of recent (cleared, no longer shown) notifications.  *  * requires access_notifications signature|system.  */ @override public statusbarnotification[] gethistoricalnotifications(string callingpkg, int count) {     // enforce() ensure calling uid has correct permission     getcontext().enforcecallingorselfpermission(             android.manifest.permission.access_notifications,             "notificationmanagerservice.gethistoricalnotifications");      statusbarnotification[] tmp = null;     int uid = binder.getcallinguid();      // noteop check make sure callingpkg matches uid     if (mappops.noteopnothrow(appopsmanager.op_access_notifications, uid, callingpkg)             == appopsmanager.mode_allowed) {         synchronized (marchive) {             tmp = marchive.getarray(count);         }     }     return tmp; } 

the viable option create notificationlistenerservice, implement method onnotificationposted , keep track locally new notifications posted apps.


Comments