I do not know if there is another way.
However, it can work. You create a notification in your wear module that starts the broadcast in wear. The broadcast (which works on wear) uses Message.API to send a message to the mobile module. There is a WearableListenerService on the mobile module that launches MainActivity on the mobile device.
In Wear, create a notification:
// Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) //.setContentTitle(mNotificationUtil.getTitle()) .setContentText("Text") .setContentIntent(getPendingIntent(this)); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Build the notification and issues it with notification manager. notificationManager.notify(1, notificationBuilder.build()); } private PendingIntent getPendingIntent(MainActivity mainActivity) { final String INTENT_ACTION = "it.gmariotti.receiver.intent.action.TEST"; Intent intent = new Intent(); intent.setAction(INTENT_ACTION); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); return pendingIntent; }
This notification triggers a broadcast message. Announce this broadcast in your clothes /AndroidManifest.xml
wear /AndroidManifes.xml
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <receiver android:name=".MyBroadcast"> <intent-filter> <action android:name="it.gmariotti.receiver.intent.action.TEST"/> </intent-filter> </receiver>
Then broadcast to send the message:
public class MyBroadcast extends BroadcastReceiver implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { Node mNode;
This code will send a message to your mobile phone. This requires wear / build.gradle
dependencies { compile "com.google.android.support:wearable:1.0.+" compile 'com.google.android.gms:play-services-wearable:+' }
On the mobile module you must implement WearableListenerService **
public class ListenerServiceFromWear extends WearableListenerService { private static final String WEAR_PATH = "/hello-world-wear"; @Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals(WEAR_PATH)) { Intent startIntent = new Intent(this, MainActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); } } }
The Mobile /AndroidManifest.xml ad must declare a Service.
<service android:name=".ListenerServiceFromWear"> <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service>
and this mobile / build.gradle dependency :
dependencies { wearApp project(':wear') compile 'com.google.android.gms:play-services-wearable:+' }