Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

384
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda