android - Getting bundle with intent null, Intent issued from helper object -
i sending intent start activity broadcast receiver using helper object follows:
broadcast receiver code: myreceiver extends broadcastreceiver{
onreceive(){ new helper(this).startmyactivity(); }
code in helper object:
helper{ private context mycontext; public helper(context c){ mycontext=c; } public void startmyactivity(){ intent i=new intent(mycontext,myactivity.class); i.addflags(intent.flag_activity_new_task); i.putextra("code", 1); mycontext.startactivity(i); } }
but when try extract out bundle in activity myactivity, null value:
myactivity extends activity{ onresume(){ bundle b=getintent().getextras(); int c=b.getint("code"); } }
why getting bundle null?
the problem need override onnewintent(intent)
in activity
, explicitly tell use new intent
@override protected void onnewintent(intent intent) { super.onnewintent(intent); setintent(intent); }
Comments
Post a Comment