Android Wear notification won't show up -
i'm trying utilize pages , stacks android wear sdk preview. without wear code notifications show fine, while if utilize wear specific code can't notification, neither on phone nor on wear emulator. i've gone throught code 10 times, think need fresh pair of eyes grab error.
this code should create, on phone, notification each tracker (an external device sending message) list of unread messages (using inboxstyle). on wear should stack multiple notifications grouped tracker, adding page each unread message.
public static void shownewmessagesnotif(context context, tracker tracker, list<message> messages) { string trackername = tracker.getname() + " - " + tracker.getphonenumber(); string contenttitle = context.getresources().getquantitystring(r.plurals.notif_new_messages, messages.size(), messages.size()); intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:" + tracker.getphonenumber())); pendingintent callpendingintent = pendingintent.getactivity(context, 0, callintent, 0); notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setsmallicon(r.drawable.ic_action_location_searching) .setcontenttitle(contenttitle) .setcontenttext(trackername) .setautocancel(true) .addaction(r.drawable.ic_action_call, context.getstring(r.string.action_call), callpendingintent); notificationcompat.inboxstyle inboxstyle = new notificationcompat.inboxstyle(); // sets title inbox style big view inboxstyle.setbigcontenttitle(contenttitle); // moves events big view (message message : messages) { inboxstyle.addline(message.gettext()); } inboxstyle.setsummarytext(trackername); // moves big view style object notification object. mbuilder.setstyle(inboxstyle); mbuilder.setcontentintent(getnotificationintent(context, tracker)); // issue notification here. notificationmanagercompat notificationmanager = notificationmanagercompat.from(context); int notifid = (int) (new_message_notif_base_id + tracker.getrowid()); //android wear notifications list<notification> wearpages = new arraylist<notification>(); (message message : messages) { notificationcompat.bigtextstyle extrapagestyle = new notificationcompat.bigtextstyle(); extrapagestyle.setbigcontenttitle(message.gettext()) .bigtext(message.getaddress()); notification extrapagenotification = new notificationcompat.builder(context) .setstyle(extrapagestyle) .build(); wearpages.add(extrapagenotification); } wearablenotifications.builder wearnotificationbuilder = new wearablenotifications.builder(mbuilder) .sethinthideicon(true) .setgroup(group_by_tracker).addpages(wearpages); // mid allows update notification later on. notificationmanager.notify(notifid, wearnotificationbuilder.build()); }
for stacking notifications, create , notify multiple notifications
notify notification you've called setgroup(trackergroupid) for summary notification want appear on phone/tablet, notify notification you've called setgroup(trackergroupid, wearablenotifications.group_order_summary) i think problem must have summary notification notifications appear on either device.
android android-notifications android-wear
No comments:
Post a Comment