Android : Restrict wearable app to receive mobile app notification?

on Monday, August 11, 2014


I am trying to develop a mobile & wearable app.


For this application, I want to add some action to the notification. E.g., Delete & Reply


Intent intent = new Intent(MyActivity.this,MyActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(MyActivity.this,0,intent,0);



Intent nextIntent = new Intent(MyActivity.this,NextActivity.class);
PendingIntent pendingIntent1 = PendingIntent.getActivity(MyActivity.this,0,nextIntent,1);

NotificationCompat.Builder notifyCompat = new NotificationCompat.Builder(MyActivity.this).addAction(R.drawable.ic_launcher,"Reply",pendingIntent)
.addAction(R.drawable.ic_launcher,"Delete",pendingIntent1)
.setContentText("Content Text")
.setContentTitle("Title")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent);

Notification notification =notifyCompat.build();
NotificationManager notifyManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notifyManager.notify(0,notification);


That is what I did to show notification with action. But, my problem is, when I click on Reply or Delete in the notification of mobile, then its launching mobile app activity which is fine. But, if I click on Delete or Reply button on the notification on Android Wear, then it has to launch Wearable Activity instead of launching Mobile App Activity.


Can someone help me on how to achieve that? If I click on an action on Android Wearable device then it has to launch Wearable App but not mobile app.


0 comments:

Post a Comment