android - Can't opening alert/Dialog box after clicking gcm notifications in phonegap -
i've implemented google cloud messaging in phonegap app, have display message in dialog box or alert box after clicking gcm notification in status bar. have googled could't work anything. gcmintentservice.java
@override public void onunregistered(context context, string regid) { log.d(tag, "onunregistered - regid: " + regid); } @override protected void onmessage(final context arg0, final intent arg1) { // todo auto-generated method stub log.i("registration", "got message!"); log.i("registration", arg1.getstringextra("message")); string message = arg1.getstringextra("message"); generatenotification(getapplicationcontext(), message); } private static void generatenotification(context context, string message) { long when = system.currenttimemillis(); notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(context.notification_service); notification notification = new notification(r.drawable.tbgicon, message, when); intent notificationintent = new intent(context, kbjphonegap.class); notificationintent.putextra("message", message); notificationintent.setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top); string title = "the business game"; pendingintent intent = pendingintent.getactivity(context, 0, notificationintent, 0); notification.setlatesteventinfo(context, title, message, intent); notification.flags |= notification.flag_auto_cancel; notification.defaults|= notification.default_lights; notification.defaults|= notification.default_vibrate; notification.flags |= notification.flag_show_lights; notificationmanager.notify(0, notification); }
here mainactivity.java in phonegap
public class mainactivity extends droidgap { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // set <content src="index.html" /> in config.xml // super.loadurl(config.getstarturl()); super.setintegerproperty("splashscreen", r.drawable.splashscreen); super.setintegerproperty("loadurltimeoutvalue", 60000); super.loadurl("file:///android_asset/www/index.html", 11000); }
please me this, have tried alertdialog box in onmessage method after receiving notification application stopping.
based on code :
intent notificationintent = new intent(context, kbjphonegap.class);
clicking on notification open kbjphonegap
activity. i'm not familiar phonegap (i know native android development), i'm not sure activity is.
if want open different activity, change line.
Comments
Post a Comment