Android: context.startActivity not start the intented activity after reboot, it just open the app -
i using 3rd-party library receive push notifications. successful make push service auto-start , receive messages after phone reboot. after reboot, click notification cannot open intented activity, open app. if have ever opened app before clicking notification, work well.
here code start activity when click notification:
intent = new intent(context, msgdetailactivity.class); i.putextra("msg_id", msgid); i.setflags(intent.flag_activity_new_task | intent.flag_activity_clear_top); context.startactivity(i);
anyone can me? lot.
edit
when clicking notification, lib send broadcast. have registered receiver receive broadcast this:
if (jpushinterface.action_notification_opened.equals(intent.getaction())){ //use code above open acticity }
here test result:
1. reboot phone -> open app -> (exit app, or not) -> receive notification -> click notification -> open intented acticity (expected)
2. reboot phone -> receive notification -> click notification -> open app, not intented activity. (not expected)
i think not sending "content-available: true" server. add info in "data" payload. , when starting activity
oncreate(bundle b){ onnewintent(getintent()); } onnewintent(intent intent){ bundle bundle=intent.getextras(); //bundle contains data payload here. }
Comments
Post a Comment