Service Android Wear:监听传入的通知

Service Android Wear:监听传入的通知,service,notifications,listener,wear-os,Service,Notifications,Listener,Wear Os,可以在可穿戴Android应用程序中监听传入的通知吗?我已尝试实现NotificationListenerService,但从未调用该服务的onNotificationPosted() public class MyListenerService extends NotificationListenerService { @Override public void onCreate() { super.onCreate(); Log.d("Not

可以在可穿戴Android应用程序中监听传入的通知吗?我已尝试实现NotificationListenerService,但从未调用该服务的onNotificationPosted()

public class MyListenerService extends NotificationListenerService {

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("NotificationListener", "This works....");
    }

    @Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        Log.i("NotificationListener", "... but this method won't be called.");
    }
}

在Android Wear中不可能使用
通知ListenerService
,因为用户没有屏幕允许这样做。 您必须在设备的应用程序中执行此操作,并使用来执行磨损侧的操作。

尝试以下操作:


adb外壳设置将安全启用的通知侦听器放置在com.google.android.wearable.app/com.google.android.clockwork.stream.NotificationCollectorService:$YOUR_PACKAGE/$YOUR_PACKAGE.$YOUR_notification_LISTENER

能否详细说明如何使用可穿戴数据层API来侦听Wear端的通知?链接如下:非常直截了当。在Android手持设备上,您可以收听传入的通知。当你收到一条信息时,你会使用
MessageApi
发送一条
信息,其中包含你需要的数据。我的意思是收听短信、未接来电等通知。关于如何在谷歌上使用
NotificationListenerService
,你有很多例子。例如:NotificationListenerService在android wear中不工作!我的问题是如何监听android wear端收到的短信通知?