java - Get Android Notification To Appear As Banner -
java - Get Android Notification To Appear As Banner -
i've looked extensively across wide range of terminology ("banner", "pop down", "notification type") , can't seem find clarity on 'think' mutual issue. if there obvious solution missed due lack of terminology please advice.
the problem this: want android notification appear "banner" drops downwards top of screen (if banner wrong word please advise). went through docs , didn't seem across setting toggles behaviour. here illustration of like:
i have notification working showing within drawer. it's not popping downwards drawer (which want).
here code, if can advise how can create appear banner appreciate it:
public void createnotification(context context, bundle extras) { notificationmanager mnotificationmanager = (notificationmanager) getsystemservice(context.notification_service); string appname = getappname(this); intent notificationintent = new intent(this, pushhandleractivity.class); notificationintent.addflags(intent.flag_activity_single_top | intent.flag_activity_clear_top); notificationintent.putextra("pushbundle", extras); pendingintent contentintent = pendingintent.getactivity(this, 0, notificationintent, pendingintent.flag_update_current); int defaults = notification.default_all; if (extras.getstring("defaults") != null) { seek { defaults = integer.parseint(extras.getstring("defaults")); } grab (numberformatexception e) {} } notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setdefaults(defaults) .setsmallicon(context.getapplicationinfo().icon) .setwhen(system.currenttimemillis()) .setcontenttitle("notificationtitle") .setticker(extras.getstring("title")) .setcontentintent(contentintent) .setautocancel(true); string messagejson = extras.getstring("data"); jsonobject parsed; string message = null; seek { parsed = new jsonobject(messagejson); message = parsed.getstring("message"); } grab (jsonexception e) { e.printstacktrace(); } if (message != null) { mbuilder.setcontenttext(message); } else { mbuilder.setcontenttext("notification"); } string msgcnt = extras.getstring("msgcnt"); if (msgcnt != null) { mbuilder.setnumber(integer.parseint(msgcnt)); } int notid = 0; seek { notid = integer.parseint(extras.getstring("notid")); } catch(numberformatexception e) { log.e(tag, "number format exception - error parsing notification id: " + e.getmessage()); } catch(exception e) { log.e(tag, "number format exception - error parsing notification id" + e.getmessage()); } mnotificationmanager.notify((string) appname, notid, mbuilder.build()); }
you need understand how windowmanager works.
you
windowmanager = (windowmanager) getsystemservice(window_service);
then want root view , utilize method addview(view, params) if want add together view.
take @ cool article, might help utilize case.
java android notifications push-notification
Comments
Post a Comment