android - Action on push notification tap in notification center -
android - Action on push notification tap in notification center -
i'm testing gcm service implement force notification in app. when receive notification shown in notification center. now, when tap on it, opens app , i'd load url web view (the url passed in payload). thought on how accomplish it?
let's assume have intent service class handles incoming gcm message (as in official demo).
let's assume pass url
server in parameter called url
.
when create intent start activity, add together url intent's extras.
protected void onhandleintent(intent intent) { bundle extras = intent.getextras(); string url = (string) extras.get("url"); string msg = (string) extras.get("message"); intent activityintent = new intent(this, demoactivity.class); activityintent.putextra ("url",url); pendingintent contentintent = pendingintent.getactivity(this, 0, activityintent, pendingintent.flag_cancel_current); notificationcompat.builder mbuilder = new notificationcompat.builder(this) .setsmallicon(r.drawable.ic_stat_gcm) .setcontenttitle("gcm notification") .setstyle(new notificationcompat.bigtextstyle() .bigtext(msg)) .setcontenttext(msg); mbuilder.setcontentintent(contentintent); mnotificationmanager.notify(notification_id, mbuilder.build()); }
when activity started, can url extras of intent , load web view.
android push google-cloud-messaging
Comments
Post a Comment