datalayerlistener 未在可穿戴设备上接收消息(意图过滤器不起作用)
datalayerlistener not receiving messages on wearable (intent filter not working)
我想向我的可穿戴设备发送消息。我将它调试到我的清单文件中的意图过滤器,更具体地说,我认为是意图过滤器中的数据标签。
这是穿戴清单文件
<service android:name="be.prizorgo.shaketosave.communication.DataLayerListenerService">
<intent-filter>
<!--<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />-->
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<data android:scheme="mobile" android:host="*"/>
<action android:name="com.google.android.gms.wearable.CHANNEL_EVENT" />
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
</intent-filter>
</service>
我想这就是问题所在。所以要清楚,如果我只使用已弃用的 bind_listener 那么它会在我添加数据标签后立即停止工作,我不知道为什么。是不是因为我没有在数据标签中使用路径,因为我读到它是可选的。
所以要清楚,一旦我添加数据标签,它就会停止工作!
替换<data android:scheme="mobile" android:host="*"/>
与<data android:scheme="wear" android:host="*"/>
我想向我的可穿戴设备发送消息。我将它调试到我的清单文件中的意图过滤器,更具体地说,我认为是意图过滤器中的数据标签。
这是穿戴清单文件
<service android:name="be.prizorgo.shaketosave.communication.DataLayerListenerService">
<intent-filter>
<!--<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />-->
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<data android:scheme="mobile" android:host="*"/>
<action android:name="com.google.android.gms.wearable.CHANNEL_EVENT" />
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
</intent-filter>
</service>
我想这就是问题所在。所以要清楚,如果我只使用已弃用的 bind_listener 那么它会在我添加数据标签后立即停止工作,我不知道为什么。是不是因为我没有在数据标签中使用路径,因为我读到它是可选的。
所以要清楚,一旦我添加数据标签,它就会停止工作!
替换<data android:scheme="mobile" android:host="*"/>
与<data android:scheme="wear" android:host="*"/>