Android Wear 2.0 - alternative to (deprecated) BIND_LISTENER

不问归期 提交于 2019-12-11 07:35:41

问题


I tried really really hard (scanning/trying sample code, reading docs …) but, haven’t been able to figure out how swap out BIND_LISTENER for the new-and-improved CapabilityApi/CapabilityClient scheme.

I recently got a Ticwatch E (from kickstarter) & its running AW 2.0. I came to AW from a Garmin FR-230 & before that, a Pebble smartwatch. I developed similar watchfaces on the Garmin + Pebble platform & one function I included in both, was to vibrate when Bluetooth connectivity breaks (so basically, I don’t leave my mobile phone at home).

I ported my watchface to AW and it works fine w/ BIND_LISTENER in the manifest pointing to my WearableListenerService class - i.e. see logs & pop-up notification. However, I get errors when I try to publish to google playstore `cause BIND_LISTENER is deprecated.

I tried changing the intent-filter to CAPABILITY_CHANGED (I was hoping it was as simple as that). I tried adding onCapabilityChanged() to this WearableListenerService – nothing/no log events.

The links below are to my watchface & the “working” source code on GitHub (w/ BIND_LISTENER). Check-out the manifest + the listener class.

Most of the examples I’ve seen are for activities or for passing data around between wear + mobile – I just want an alert when connectivity changes. A connectivity icon pops up on my watch when BT is gone so, it’s gotta be possible to get an alert.

Newbie Android Wear developer & struggling with the documentation. Appreciate an explicit example, if possible.

https://android-developers.googleblog.com/2016/04/deprecation-of-bindlistener.html https://play.google.com/store/apps/details?id=com.antonio_asaro.www.marvin_watchface https://github.com/antonioasaro/Android-Marvin_Watchface

Thanks, --Antonio

来源:https://stackoverflow.com/questions/48286073/android-wear-2-0-alternative-to-deprecated-bind-listener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!