问题
I am trying to implement a way to detect the notifications that are sent to the android wearable devices.
After googling around, I have found it is not possible to use notificationListenerService on the wearable.
In current implementation, I have implemented the notificationListenerService on the mobile handheld and am using the DataLayer to send the notifications over.
My issue is:
With the notificationListener, it detects everything that appears. Is there a reliable way to detect which notifications will be sent to the wearable? For example, I don't want twilight or other things that are not sent to the wearable to be sent across the dataLayer
回答1:
Yes, it is possible, just filter your Notifications
in NotificationListenerService
by FLAG_LOCAL_ONLY which is public.
It is set by .setLocalOnly()
and if it is true notification is not send to Wear device.
来源:https://stackoverflow.com/questions/28469863/notificationlistenerservice-wearable