Try to search your question here, if you can't find : Ask Any Question Now ?

get list of active notifications in androidStudio

HomeCategory: stackoverflowget list of active notifications in androidStudio
Avatarpushpa asked 3 months ago

Hello I’m trying to get a list of all active notifications in java android studio and I’m having trouble figuring out how to do so with the information given in the documentation.

My plan is to start with creating a StatusBarNotification object and then calling getActiveNotifications(), but I’m having trouble with the first part of declaring the StatusBarNotification object In my file “” the getCurrentNotifications() function gets called when a button is pressed:

package com.example.notificationstest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;

class NotificationMonitor extends NotificationListenerService{

private String TAG = this.getClass().getSimpleName();

Context context;
public void onCreate() {
    Log.d("myTag", "onCreate()");


public void onNotificationPosted(StatusBarNotification sbn){
    Log.d("myTag", "onNotificationPosted()");


public void getCurrentNotifications(){
    Log.d("myTag", "getCurrentNotifications()");

    //create statusBarNotification object
    StatusBarNotification sbn = new StatusBarNotification();

    //get list of active notifications
    //ActiveNotifications[] = sbn.getActiveNotifications();


StatusBarNotification is described as a class I believe from what I’ve read online:

which makes me think I can just create a new instance of said class as an object? I’ve been looking at many notification listener example projects online but they never directly declare StatusBarNotification which has me confused.

Thanks, -Martin

1 Answers
Best Answer
AvatarJyoti answered 3 months ago
Your Answer

19 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By :