Android Wear Watch Face Vibrate With Screen Off
Solution 1:
When the watch goes into ambient mode, it goes into a deep sleep. As a result, code written with Handler
will not run. As a result, you should use AlarmManager
. For details on how to implement this, you should refer to the "Update more frequently" section on this page about the always-on functionality of Android Wear.
With regards to Bluetooth debug mode, I suspect that it works because the watch never goes into deep sleep. The same happens when I develop apps while the watch is docked.
Lastly, as for the wake up frequency, I think your functionality is fine as it only fires once an hour. For others reading this, please refrain from waking the watch up more than once a minute as this will severely impact battery life. Always test your watch face for battery life before uploading to the Play Store.
Solution 2:
in my project i use Alarm manager with MyIntentService extends IntentService. To wake up (on screen) device in onHandleIntent use following:
if (intent.getAction() != null) {
tmp = intent.getAction();
PowerManagerpowerManager= (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), TAG);
wakeLock.setReferenceCounted(true);
if(!wakeLock.isHeld()) {
wakeLock.acquire();
}
}
Post a Comment for "Android Wear Watch Face Vibrate With Screen Off"