Java 在智能手机上获取所有活动通知时遇到一些问题

Java 在智能手机上获取所有活动通知时遇到一些问题,java,c#,android,unity3d,plugins,Java,C#,Android,Unity3d,Plugins,我有一个unity应用程序,使用java插件,可以接收传入的通知,但现在我需要获取所有活动通知。。。这里是我的java代码,我用它来实现: public void getNotifications() { Log.i("GetActiveNotifications", "Getting.............."); sem.acquireUninterruptibly(); for

我有一个unity应用程序,使用java插件,可以接收传入的通知,但现在我需要获取所有活动通知。。。这里是我的java代码,我用它来实现:

 public void getNotifications() {

        Log.i("GetActiveNotifications", "Getting..............");

            sem.acquireUninterruptibly();

            for ( StatusBarNotification notification : getActiveNotifications()) 
            {
                Log.i("ActiveNotifi:", "[");
          
                Log.i("ActiveNotifi:", notification.getPackageName() + "     " +
                        notification.getNotification().extras.getString("android.title") + " " +
                        notification.getNotification().extras.getCharSequence("android.text").toString() + "///");

                ActiveNotifications =
                        notification.getNotification().extras.getString("android.title") + " " +
                        notification.getNotification().extras.getCharSequence("android.text").toString();
                callback.GetActiveNotifications(ActiveNotifications);
                Log.i("ActiveNotifi:", "]");           

        
            }
        sem.release();
            Log.i("GetActiveNotifications", "Done!!!..............");

    }
“Getting…”消息-这是我在logcat中看到的最后一条消息(mt应用程序没有崩溃,但同时什么也没有发生)。。。我读到
acquireUnterruptibly()
在线程被中断时无效,它保持块状态,直到从信号量获得许可。所以我不知道,我必须做什么,因为我的应用程序可以接收传入的通知,我授予访问通知的权限。。。如果我不使用
acquireUnterruptibly()
我在logcat中有以下消息:

Notification listener service not yet bound.
例如,在我的android应用程序(只有Java,没有unity)中,我这样做:

public void getNotifications() {
        Log.i(TAG, "Waiting for MyNotificationService");
        NotificationService myNotificationService = NotificationService.get();
        Log.i(TAG, "Active Notifications: [");
       for (StatusBarNotification notification : myNotificationService.getActiveNotifications()) {
        
           Log.i("ActiveNotifications:", notification.getPackageName() + "     " +
                   notification.getNotification().extras.getString("android.title") + " " +
                   notification.getNotification().extras.getCharSequence("android.text").toString() + "///");

        }
        Log.i(TAG, "]");
    }
在此行上
NotificationService myNotificationService=NotificationService.get()我向我的另一个类发送地址,其中我有:

    static NotificationService _this;
    static Semaphore sem = new Semaphore(0);

    public static NotificationService get() {
        sem.acquireUninterruptibly();
        NotificationService ret = _this;
        sem.release();
        return ret;
    }
它工作得很完美,但是如果我使用unity,没有任何效果。。。你能帮帮我吗?提前谢谢你