如何发送和接收消息 Android Wear
How to Send and Receive Messages Android Wear
我正在尝试将字符串从我的 Moto 360 发送到 Android 应用程序!但我不明白如何在文档中实现代码,谁能帮我解释一下发送数据的步骤!
http://developer.android.com/training/wearables/data-layer/messages.html
看一个示例,这一行准确地显示了如何发送消息:
private void sendStartActivityMessage(String node) {
Wearable.MessageApi.sendMessage(
mGoogleApiClient, node, START_ACTIVITY_PATH, new byte[0]).setResultCallback(
new ResultCallback<SendMessageResult>() {
@Override
public void onResult(SendMessageResult sendMessageResult) {
if (!sendMessageResult.getStatus().isSuccess()) {
Log.e(TAG, "Failed to send message with status code: "
+ sendMessageResult.getStatus().getStatusCode());
}
}
}
);
}
如果信息太多,MessageApi
的更简单的教程应该只需 google 搜索即可。试试这个:http://www.binpress.com/tutorial/a-guide-to-the-android-wear-message-api/152 看起来很合理。
我正在尝试将字符串从我的 Moto 360 发送到 Android 应用程序!但我不明白如何在文档中实现代码,谁能帮我解释一下发送数据的步骤!
http://developer.android.com/training/wearables/data-layer/messages.html
看一个示例,这一行准确地显示了如何发送消息:
private void sendStartActivityMessage(String node) {
Wearable.MessageApi.sendMessage(
mGoogleApiClient, node, START_ACTIVITY_PATH, new byte[0]).setResultCallback(
new ResultCallback<SendMessageResult>() {
@Override
public void onResult(SendMessageResult sendMessageResult) {
if (!sendMessageResult.getStatus().isSuccess()) {
Log.e(TAG, "Failed to send message with status code: "
+ sendMessageResult.getStatus().getStatusCode());
}
}
}
);
}
如果信息太多,MessageApi
的更简单的教程应该只需 google 搜索即可。试试这个:http://www.binpress.com/tutorial/a-guide-to-the-android-wear-message-api/152 看起来很合理。