OnMessageReceived不会调用WearableListenerService [英] OnMessageReceived not called in WearableListenerService

查看:231
本文介绍了OnMessageReceived不会调用WearableListenerService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序磨损使用Eclipse工作IDE.I现在用同样的包名是否有磨损的应用程序和移动应用程序,我包装耐磨应用程序手动根据的谷歌文档。一切正在fine.it使用USB调试与手机安装了Android上的磨损模拟器。

I am working on android wear app using Eclipse IDE.I am using same package names for wear app and mobile app and i am packing wearable app manually according to google documentation.Everything is working fine.it is installed on Android wear emulator using usb debugging with phone.

我的问题是

List<Node> nodeList=getNodes();
for(Node node : nodeList) {
    Log.v(" ", "telling " + node.getId() );

    PendingResult<MessageApi.SendMessageResult> result = Wearable.MessageApi.sendMessage(
        mGoogleApiClient,
        node.getId(),
        START_ACTIVITY_PATH,
        null
    );

    result.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
        @Override
        public void onResult(MessageApi.SendMessageResult sendMessageResult) {
            Log.v(" ", "Phone: " + sendMessageResult.getStatus().getStatusMessage());
        }
    });
}

在OnPeerConnected方法设备凝视时,却OnMessageReceived从来没有所谓的WearableListenerService.This运行的是我的WearableListenerService code:

the OnPeerConnected method is running when devices are peered but OnMessageReceived never called in WearableListenerService.This is my WearableListenerService code:

public class DataLayerListenerService extends WearableListenerService {

    private static final String TAG = "DataLayerSample";
    private static final String START_ACTIVITY_PATH = "/start/MainActivity";
    private static final String DATA_ITEM_RECEIVED_PATH = "/data-item-received";
    private static final String LOG_TAG = "log";
    @Override
    public void onPeerConnected(Node peer) {
        super.onPeerConnected(peer);

        String id = peer.getId();
        String name = peer.getDisplayName();

        Log.d(LOG_TAG, "Connected peer name & ID: " + name + "|" + id);
    }
    @Override
    public void onDataChanged(DataEventBuffer dataEvents) {
        System.out.println("Recevive message3");
    }

    @Override
    public void onMessageReceived(MessageEvent messageEvent) {
        System.out.println("service watch message1");
        if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) {
            System.out.println("service watch message2");
            Intent startIntent = new Intent(this, MainActivity.class);
            startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(startIntent);
        }
    }
}

此外,在logcat的一个警告消息总是出现:

Also a warning message in Logcat always appears :

应用程序不匹配记录的应用程序键:的AppKey [com.myapp,c3f31717fa35401056c20a2798907f1232efa75e] =的AppKey [com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]

app does not match record's app key: AppKey[com.myapp,c3f31717fa35401056c20a2798907f1232efa75e] != AppKey[com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]

如果应用程序键,这两个应用程序应该是一样的话,我怎么可以创建相同的应用程序的密钥进行的应用程序。

If app key for both apps should be same then how can i create same app key for both the apps.

任何帮助是非常AP preciated, 谢谢你。

Any help is highly appreciated, Thanks.

推荐答案

你的错误信息:

应用程序不匹配记录的应用程序键:   的AppKey [com.myapp,c3f31717fa35401056c20a2798907f1232efa75e]!=   的AppKey [com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]

app does not match record's app key: AppKey[com.myapp,c3f31717fa35401056c20a2798907f1232efa75e] != AppKey[com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]

表示,您的应用程序都使用不同的密钥签名。
手机和耐磨的应用程序包的名称是相同的 - 这是很好的,但他们也需要共享相同的签名。这就是为什么邮件无法递送 - 耐磨的应用程序被认为是基于包名和签名相同的应用程序的一部分。

Indicated that your apps are signed with the different keys.
Package names of phone and wearable apps are the same - that is good, but they also need to share the same signature. This is the reason why messages cannot be delivered - wearable apps are recognized as "part of the same app" based on the package name and signature.

请确保您有相同的密钥签名的这两个应用程序。如果您正在测试的自动安装功能,请务必从手表仿真器卸载可穿戴应用程序的调试版本。

Please make sure that you have both apps signed with the same key. If you are testing the autoinstallation feature please make sure to uninstall the debug version of wearable app from watch emulator.

这篇关于OnMessageReceived不会调用WearableListenerService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆