Reputation: 5892
Is it possible to have a notification that shows a different text (content title and content text) in the Android wear device and in the mobile device?
Upvotes: 2
Views: 329
Reputation: 807
Actually you can achieve this using
.setGroup(GROUP_KEY)
.setGroupSummary(true)
On your phone notification. Then create a notification with the data that you want to show on the watch and set
.setGroup(GROUP_KEY)
to the same group that your phone notification. This is used to show stack notifications but if you use it with only one then it does the trick.
Complete documentation: Stacking Notifications
Upvotes: 0
Reputation: 645
Yes, it's possible now with little tricky and bug on Android wear which help's us. More Over this trick doesn't need Android wear API, just a normal Notification with RemoteViews is enough.
NotificationCompat.Builder mBuilder;
mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentText("This msg won't display in your phone, only on wear you can see.")
.setContentTitle("Hello")
.setContentIntent(
PendingIntent.getActivity(context, 10,intent,PendingIntent.FLAG_ONE_SHOT));
NotificationManager mNM = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = mBuilder.build();
RemoteViews contentView = new RemoteViews(context.getPackageName(),
R.layout.notification_layout);
contentView.setTextViewText(R.id.noti_text,"This message won't display in your wear device, only on phone you can see.");
contentView.setImageViewResource(R.id.noti_image,R.drawable.ic_launcher);
notification.contentView = contentView;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNM.notify(50, notification);
Now run the app on your device and check the notification on both watch and phone, the content inside the RemoteViews won't display in your watch but on phone it will display and if you remove the .setContentTitle() & .setContentText(), then the RemoteViews content will be displayed on both watch and phone too.
Upvotes: 0
Reputation: 42208
Not at the moment. However, you can achieve this effect in the following way:
setLocalOnly(true)
DataItem
using a DataAPI
that describes the notification and changed textDataItem
, post the notification with different text, again setting setLocalOnly(true)
setDeleteIntent
so you know, when there are dismissedDataItem
from point 2.DataItem
gets deleted, you will receive a callback; delete the remaining notificationThere might be some corner cases here I don't see immediately, but the general approach should allow you to achieve what you want.
Upvotes: 1