Oncapabilitychanged Is Not Fired On Both Handheld And Wearable While Disabling/enabling Connections
Solution 1:
You need to include an android:path
element that identifies the (fully-qualified) capability you're listening for:
<intent-filter><actionandroid:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" /><dataandroid:host="*"android:scheme="wear"android:path="/com.mypackagename.my_capability_name"/></intent-filter>
where my_capability_name
is defined in the wear.xml
of your app running on the other device:
<?xml version="1.0" encoding="utf-8"?><resources><string-arrayname="android_wear_capabilities"><item>my_capability_name</item></string-array></resources>
as documented at https://developer.android.com/training/wearables/data-layer/messages.html#AdvertiseCapabilities.
A couple of caveats, however:
- Because your app will run every time the devices dis/connect, you could see significant battery drain as a result.
- As with all other manifest-declared broadcast receivers, this will stop working in Android O: https://developer.android.com/preview/features/background.html#broadcasts
Post a Comment for "Oncapabilitychanged Is Not Fired On Both Handheld And Wearable While Disabling/enabling Connections"