android - Custom layout for push notifications -


i using parse.com send push notifications, , created custom layout notifications.

to that, extended class parsepushbroadcastreceiver this:

public class pushbroadcastreceiver extends parsepushbroadcastreceiver {     @override     protected notification getnotification(context context, intent intent) {         notification notification = new notificationcompat.builder(context)                 .addextras(intent.getextras())                 .setsmallicon(r.drawable.push_icon)                 .setlargeicon(bitmapfactory.decoderesource(context.getresources(), r.drawable.push_icon))                 .setvibrate(new long[]{0, 100, 200, 100, 200, 100})                 .setstyle(new notificationcompat.bigtextstyle())                 .build();          bundle extras = intent.getextras();          jsonobject json = new jsonobject();         string title = "";         string message = "";         string color = "";          try {             json = new jsonobject(extras.getstring("com.parse.data"));             title = json.getstring("alert");             message = json.getstring("message");             color = json.getstring("color");         } catch (jsonexception e) {             log.e("pushbroadcastreceiver", "could not parse notification json:\n" + extras.getstring("com.parse.data"));             e.printstacktrace();             return null;         }          remoteviews contentview = new remoteviews(context.getpackagename(), r.layout.notification);         contentview.settextviewtext(r.id.title, title);         contentview.settextviewtext(r.id.message, message);         contentview.setint(r.id.color, "setbackgroundcolor", color.parsecolor(color));          if (build.version.sdk_int >= build.version_codes.jelly_bean) {             notification.bigcontentview = contentview;         } else {             notification.contentview = contentview;         }          return notification;     } } 

issue update:

the layout works first push notification sent. whenever device receives notification, previous "refreshed", , layout default, rather custom one.

what need in order have same layout time?


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -