0

我正在尝试将字符串从我的 Moto 360 发送到 Android 应用程序!但我不明白如何在文档中实现代码,谁能帮我解释一下发送数据的步骤!

http://developer.android.com/training/wearables/data-layer/messages.html

4

1 回答 1

1

看一个示例,这一行准确地显示了如何发送消息:

http://developer.android.com/samples/DataLayer/Application/src/com.example.android.wearable.datalayer/MainActivity.html#l335

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应该只是谷歌搜索。试试这个: http: //www.binpress.com/tutorial/a-guide-to-the-android-wear-message-api/152它看起来很合理。

于 2015-03-05T22:21:37.123 回答