Problems with Android intents after activating app from background -
i've started android development. i've created app engine connected android project in eclipse following guide: creating app engine connected android project.
the app works, when task goes background , activated again receiving gcm message, intents invoked gcmintentservice class not reach corresponding activity. might problem?
public class gcmintentservice extends gcmbaseintentservice { [...] @override public void onmessage(context context, intent intent) { sendnotificationintent(context, "message received via google cloud messaging:\n\n" + intent.getstringextra("message"), true, false); } [...] private void sendnotificationintent(context context, string message, boolean iserror, boolean isregistrationmessage) { intent notificationintent = new intent(context, registeractivity.class); notificationintent.putextra("gcmintentservicemessage", true); notificationintent.putextra("registrationmessage", isregistrationmessage); notificationintent.putextra("error", iserror); notificationintent.putextra("message", message); notificationintent.addflags(intent.flag_activity_new_task); startactivity(notificationintent); } [...] }
thanks in advance!
// add permission <uses-permission android:name="android.permission.wake_lock" /> @override public void onmessage(context context, intent intent) { sendnotificationintent(context, "message received via google cloud messaging:\n\n" + intent.getstringextra("message"), true, false); context.sendbroadcast(intent) ; } private void sendnotificationintent(context context, string message, boolean iserror, boolean isregistrationmessage) { intent notificationintent = new intent(context, registeractivity.class); notificationintent.putextra("gcmintentservicemessage", true); notificationintent.putextra("registrationmessage", isregistrationmessage); notificationintent.putextra("error", iserror); notificationintent.putextra("message", message); notificationintent.addflags(intent.flag_activity_new_task); notificationmanager notificationmanager = (notificationmanager)context.getsystemservice(context.notification_service); notification notification = nenotification(r.drawable.ic_launcher,"title",system.currenttimemillis()); pendingintent intents = pendingintent.getactivity(context, 0, notificationintent, intent.flag_activity_brought_to_front); notification.setlatesteventinfo(context , context.getstring(r.string.app_name), tickertext , intents ); notification.flags |= notification.flag_auto_cancel; notificationmanager.notify(100, notification); } public class appbroadcastreceiver extends broadcastreceiver{ @override public void onreceive(context context, intent intent) { // todo auto-generated method stub if(intent.getaction() == "appreceiver") { // intent gcminit intent , can data intent } }
}
// in menifest file <receiver android:name="appbroadcastreceiver" > <intent-filter> <action android:name="appreceiver" > </action> </intent-filter> </receiver>
Comments
Post a Comment