android – Trouble getting Wearable app to wake and display data/message when Mobile app sends Data-ThrowExceptions

Exception or error:

I want to send an image and some data to my Wearable, which I have been able to do, but I cannot get it to wake up the app and show the data incase the app is closed.

I have added a

public class WearDataLayerListenerService extends WearableListenerService implements DataClient.OnDataChangedListener, MessageClient.OnMessageReceivedListener

and can send the Wearable a message to open it up, but it does not show the data from the sent message. The onDataChanged does not fire in the main activity. My second send once it is open seems to work but if I shut down the app or use the hardware button to suspend/sleep it, the initial message/image/vibration does not fire.

I am not exactly sure how to address this and was hoping somebody could point me in the right direction.

Regardless of the fact the app is closed, asleep, whatever. I want it to open and show the sent data with a high degree of certainty.

I could have the WearableDataLayerListenerService intercept all messages and pass them on to the MainActivity. Right now it is just starting the activity:

private void startMainActivity() {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    startActivity(intent);
}

which has a:

@Override
public void onDataChanged(DataEventBuffer dataEventBuffer)

When the app is started and ready, this works well, but not in any other circumstance.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *