WearOS 永远在线模式无法在设备上运行
WearOS always-on mode not working on device
我是 WearOS 的新手,我需要开发一个 activity 跟踪应用程序。我从 Google 为 Always-on 应用程序提供的示例开始。从这个跟踪可以看出,在模拟器中一切正常:
2020-05-27 15:44:11.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587051002(false)
2020-05-27 15:44:12.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587052002(false)
2020-05-27 15:44:13.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587053003(false)
2020-05-27 15:44:14.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587054002(false)
2020-05-27 15:44:14.587 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: Ambient: onEnterAmbient
2020-05-27 15:44:14.587 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587054587(true)
2020-05-27 15:44:20.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587060002(true)
2020-05-27 15:44:30.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587070003(true)
2020-05-27 15:44:40.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587080002(true)
2020-05-27 15:44:50.005 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587090005(true)
2020-05-27 15:44:50.095 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: Ambient: onExitAmbient
2020-05-27 15:44:50.096 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587090096(false)
2020-05-27 15:44:51.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587091002(false)
2020-05-27 15:44:52.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587092002(false)
2020-05-27 15:44:53.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587093002(false)
但是当我在真实设备(Suunto 7、WearOS 2.17)上尝试时,它不起作用。当我转动手腕时,应用程序没有进入环境模式,它给出了这个错误 Error on detecting ambient animation
而不是调用 onEnterAmbient()
它只是调用 onPause()
。只要我点击显示屏,就会调用 onResume()。此处完整跟踪:
2020-05-27 16:34:41.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590081001(false)
2020-05-27 16:34:42.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590082002(false)
2020-05-27 16:34:43.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590083001(false)
2020-05-27 16:34:44.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590084001(false)
2020-05-27 16:34:45.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590085002(false)
2020-05-27 16:34:45.657 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: onPause()
2020-05-27 16:34:45.755 13984-13984/com.example.android.wearable.wear.alwayson E/ViewRootImpl[MainActivity]: Error on detecting ambient animation
2020-05-27 16:34:50.339 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_ENTER, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271754, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.362 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271754, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.375 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271791, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.377 13984-13984/com.example.android.wearable.wear.alwayson I/chatty: uid=10078(com.example.android.wearable.wear.alwayson) identical 2 lines
2020-05-27 16:34:50.379 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271791, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.387 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_ENTER, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271792, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.389 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271792, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.391 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271805, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.394 13984-13984/com.example.android.wearable.wear.alwayson I/chatty: uid=10078(com.example.android.wearable.wear.alwayson) identical 2 lines
2020-05-27 16:34:50.395 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271805, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.503 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: onResume()
2020-05-27 16:34:50.507 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590090507(false)
2020-05-27 16:34:51.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590091002(false)
2020-05-27 16:34:52.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590092002(false)
2020-05-27 16:34:53.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590093001(false)
2020-05-27 16:34:54.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590094001(false)
2020-05-27 16:34:55.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590095001(false)
我是不是做错了什么?代码正是Googlehere提供的代码。关于如何解决它的任何线索?
谢谢
我发现了问题。要使此模式正常工作,必须在设置 -> 显示 -> 常亮屏幕中将显示屏设置为常亮。
这并不是我真正想要的,因为 Suunto 应用程序可以在没有激活这种模式的情况下实现这一点,但我想这是因为它是一个系统应用程序。
我是 WearOS 的新手,我需要开发一个 activity 跟踪应用程序。我从 Google 为 Always-on 应用程序提供的示例开始。从这个跟踪可以看出,在模拟器中一切正常:
2020-05-27 15:44:11.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587051002(false)
2020-05-27 15:44:12.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587052002(false)
2020-05-27 15:44:13.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587053003(false)
2020-05-27 15:44:14.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587054002(false)
2020-05-27 15:44:14.587 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: Ambient: onEnterAmbient
2020-05-27 15:44:14.587 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587054587(true)
2020-05-27 15:44:20.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587060002(true)
2020-05-27 15:44:30.003 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587070003(true)
2020-05-27 15:44:40.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587080002(true)
2020-05-27 15:44:50.005 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587090005(true)
2020-05-27 15:44:50.095 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: Ambient: onExitAmbient
2020-05-27 15:44:50.096 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587090096(false)
2020-05-27 15:44:51.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587091002(false)
2020-05-27 15:44:52.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587092002(false)
2020-05-27 15:44:53.002 4296-4296/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590587093002(false)
但是当我在真实设备(Suunto 7、WearOS 2.17)上尝试时,它不起作用。当我转动手腕时,应用程序没有进入环境模式,它给出了这个错误 Error on detecting ambient animation
而不是调用 onEnterAmbient()
它只是调用 onPause()
。只要我点击显示屏,就会调用 onResume()。此处完整跟踪:
2020-05-27 16:34:41.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590081001(false)
2020-05-27 16:34:42.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590082002(false)
2020-05-27 16:34:43.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590083001(false)
2020-05-27 16:34:44.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590084001(false)
2020-05-27 16:34:45.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590085002(false)
2020-05-27 16:34:45.657 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: onPause()
2020-05-27 16:34:45.755 13984-13984/com.example.android.wearable.wear.alwayson E/ViewRootImpl[MainActivity]: Error on detecting ambient animation
2020-05-27 16:34:50.339 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_ENTER, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271754, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.362 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271754, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.375 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271791, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.377 13984-13984/com.example.android.wearable.wear.alwayson I/chatty: uid=10078(com.example.android.wearable.wear.alwayson) identical 2 lines
2020-05-27 16:34:50.379 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271791, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.387 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_ENTER, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271792, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.389 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Dropping event due to no window focus: MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271792, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.391 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271805, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.394 13984-13984/com.example.android.wearable.wear.alwayson I/chatty: uid=10078(com.example.android.wearable.wear.alwayson) identical 2 lines
2020-05-27 16:34:50.395 13984-13984/com.example.android.wearable.wear.alwayson W/ViewRootImpl[MainActivity]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=99.78022, y[0]=99.78022, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=221271805, downTime=221262644, deviceId=2, source=0x1002 }
2020-05-27 16:34:50.503 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: onResume()
2020-05-27 16:34:50.507 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590090507(false)
2020-05-27 16:34:51.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590091002(false)
2020-05-27 16:34:52.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590092002(false)
2020-05-27 16:34:53.002 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590093001(false)
2020-05-27 16:34:54.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590094001(false)
2020-05-27 16:34:55.001 13984-13984/com.example.android.wearable.wear.alwayson D/MainActivity: loadDataAndUpdateScreen(): 1590590095001(false)
我是不是做错了什么?代码正是Googlehere提供的代码。关于如何解决它的任何线索? 谢谢
我发现了问题。要使此模式正常工作,必须在设置 -> 显示 -> 常亮屏幕中将显示屏设置为常亮。 这并不是我真正想要的,因为 Suunto 应用程序可以在没有激活这种模式的情况下实现这一点,但我想这是因为它是一个系统应用程序。