android - NotificationCompat Ticker Text Not Showing When Updating Notification -
background
this app writing familiarize myself of apis, serves no real purpose other demonstrate functionality in android. have service running in foreground (startforeground), , has ongoing notification when tapped returns application. service listens broadcasts , logs them db.
start service, create notification
i create notification using notificationcompat.builder in oncreate of service:
@override public void oncreate() { super.oncreate(); log.v(tag, "oncreate"); // notification manager update notifications mnotificationmanager = (notificationmanager) getsystemservice(context.notification_service); intent openappintent = new intent(this, mainactivity.class); openappintent.setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top); pendingintent selectnotifpendingintent = pendingintent.getactivity(this, 0, openappintent, 0); // build notification show mnotificationbuilder = new notificationcompat.builder(this) .setcontenttitle("monitor service") .setcontenttext("logging system events") .setticker("starting monitor service") .setsmallicon(r.drawable.ic_stat_cloud) .setcontentintent(selectnotifpendingintent) .setonlyalertonce(false) .setpriority(notificationcompat.priority_low) .setuseschronometer(true); // start service in foreground startforeground(monitorservice.notification_id_foreground, mnotificationbuilder.build()); // more code.... } when service starts, notification , ticker text both shown on versions of android:

next, update notification
i added callback interface service, update notification changing ticker text , content text:
@override public void updatenotificationticker(string newtickertext) { log.d(tag, "updatenotificationticker"); if (mnotificationbuilder != null && mnotificationmanager != null) { mnotificationbuilder.setticker(newtickertext); mnotificationbuilder.setcontenttext(newtickertext); mnotificationmanager.notify(notification_id_foreground, mnotificationbuilder.build()); } } to test updating notification, had broadcastreceiver listen time tick broadcasts, , call updatenotificationticker current time:
else if (action.equals(android.content.intent.action_time_tick)) { simpledateformat sdf = new simpledateformat("h:mm aa", locale.us); string message = "the time " + sdf.format(new date()); newlogentry.setmessage(message); // update ticker notification time if (mnotificationcallback != null) { mnotificationcallback.updatenotificationticker(message); } } this works on (almost) every version of android, ticker text flashes , content text updated on notification:
- android 2.2 (api 8)
- android 4.0.3 (api 15)
- android 4.1.2 (api 16)
- android 4.2.2 (api 17)


different behavior on android 2.3.3
when run on android 2.3.3 (api 10) emulator or device, ticker text shown when first starting service (seen in 1st screenshot: "starting monitor service"). however, ticker text never shown when updating notification, though content text update.

questions
- am setting
notificationcompat.builderin way causing ticker text not show on android 2.3.3? - or, android 2.3.3 behave differently other versions when showing ticker text while updating ongoing
notification? - or, defect
notificationcompat.buildernot working on android 2.3.3?
Comments
Post a Comment