Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

391
Views
Is there any way to get the device notification history?

I'm developing an usage statistics app and I'm wondering how other apps can access to the devices notification history.

Right now I'm working with NotificationListenerService, but this only can handle the new notifications received, not the past ones. I've checked Android DOC and found some methods which are 'system only' , like getHistoricalNotifications(), or that require ACCESS_NOTIFICATION permission.

The thing is that there are a few apps out there which actually can access to notification history data.

Android DOC also shows a new API on Android Q called NotificationStats but is not available at the moment.

Any tips? Is this even possible in a non-hacky way?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

ActionDash shows this enter image description here

As mentioned by you getHistoricalNotifications is a system-level API only accessed by system apps, so Google Digital Wellbeing being a system app can show these.

So I think there is no way to get a history of notifications for 3rd party apps.

/**
         * System-only API for getting a list of recent (cleared, no longer shown) notifications.
         *
         * Requires ACCESS_NOTIFICATIONS which is signature|system.
         */
        @Override
        public StatusBarNotification[] getHistoricalNotifications(String callingPkg, int count) {
            // enforce() will ensure the calling uid has the correct permission
            getContext().enforceCallingOrSelfPermission(
                    android.Manifest.permission.ACCESS_NOTIFICATIONS,
                    "NotificationManagerService.getHistoricalNotifications");

            StatusBarNotification[] tmp = null;
            int uid = Binder.getCallingUid();

            // noteOp will check to make sure the callingPkg matches the uid
            if (mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg)
                    == AppOpsManager.MODE_ALLOWED) {
                synchronized (mArchive) {
                    tmp = mArchive.getArray(count);
                }
            }
            return tmp;
        }
over 4 years ago · Santiago Trujillo Report

0

You should store the app notification data when notification is received into the sql database and when you want the history of the respective application's notification, you can easily get all notification by putting a query into the sql database.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!