Is it possible to listen for incoming notifications in an Wearable Android App? I have tried to implement a NotificationListenerService, but the service's onNotificationPosted() is never called:
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.");
}
}
It's not possible to use a NotificationListenerService
in Android Wear as there is no screen for the user to allow this.
You have to do it in the device's app and to use the Wearable Data Layer API to perform the action on Wear's side.
Try this:
adb shell settings put secure enabled_notification_listeners com.google.android.wearable.app/com.google.android.clockwork.stream.NotificationCollectorService:$YOUR_PACKAGE/$YOUR_PACKAGE.$YOUR_NOTIFICATION_LISTENER
来源:https://stackoverflow.com/questions/27185609/android-wear-listen-to-incoming-notifications