user3498416
user3498416

Reputation: 3

Android Wear - Open on phone

I was wondering could anybody help me. I have two applications, the parent mobile application and the android wear application.

I want to add a button to open the parent application from the watch like in many applications for android wear but I cant seem to find anything to help me.

So far I'm running something like this which just plays the open on phone animation on the watch and then I'm not sure where to go from there to actually open the parent application.

@Override
    public void onClick(WearableListView.ViewHolder viewHolder) {
        switch (viewHolder.getPosition()) {
            case 0:
                //Do something
                Intent intent = new Intent(this, SelectActivity.class);
                startActivity(intent);
                break;
            case 1:
                //Do something else
                break;
            case 2:
                Intent intentOpen = new Intent(context,       ConfirmationActivity.class);
                    intentOpen.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,     ConfirmationActivity.OPEN_ON_PHONE_ANIMATION);
                    startActivity(intentOpen);
            break;
    }
}

Upvotes: 0

Views: 1282

Answers (1)

dazza5000
dazza5000

Reputation: 7628

You need to create a WearableListenerService. A good example of how to do that is here:

https://gist.github.com/gabrielemariotti/117b05aad4db251f7534

Once you receive the message you can open the parent application using an intent with the following:

getApplicationContext().startActivity(intent);

Upvotes: 1

Related Questions