0
votes

We are trying to connect our Android wear app with a device. Connection from wear to the device works fine: the device receives messages from the wear. But messages sent from the device to the wear are not received in the wear if the wifi is turned on. With the wifi turned off, the wear received messages and everything works fine. (We are using a Nexus 5 and Moto 360, bluetooth is turned on in both devices)

1

1 Answers

1
votes

There is a "problem" in most of the Google connection examples. Review your connection code, specially the place when you get the nodes to send the final message. Most of the connections examples take on the first node to send the info, but the first node may not be nearby. You must iterate on the list of nodes in order to find the nearby node and send the message to this.

private Node getNodeNearby(NodeApi.GetConnectedNodesResult nodes)
{
    List<Node> nodeList = nodes.getNodes();
    Node nodeNearby = null;
    for (Node node : nodeList)
    {
        if (node.isNearby())
        {
            nodeNearby = node;
            break;
        }
    }
    return nodeNearby;
}

The handheld and the wearable may contain more than one node... you should make sure that you send the information to the correct node.