android - how to send extras to an activity with Intents? -


i have broadcastreceiver listens incoming sms messages. while new sms arrives, displays notification user can click on , open app. want pass message text activity.

inside receiver:

notification notifacation = new notification(); notifacation.icon = icon; notifacation.tickertext = tickertext; notifacation.when = system.currenttimemillis(); bundle bundle = new bundle(); bundle.putstring("sms_parameters", smsparameters);  intent notificationintent = new intent(context, myactivity.class); notificationintent.putextra("sms_parameters", bundle); pendingintent contentintent = pendingintent.getactivity(context, 0,   notificationintent, 0); notifacation.setlatesteventinfo(context, tickertext, message, contentintent); notificationmanager.notify(1, notifacation); 

inside activity:

@override public void onresume() {     bundle bundle = this.getintent().getextras();     if( bundle != null) {         string smsparameters = bundle.getstring("sms_parameters");         log.d(debug_tag, "sms_parameters: " + smsparameters);         toast.maketext(this, smsparameters, toast.length_long).show();     }        super.onresume(); } 

the problem bundle null.

any idea?

i don't see adding bundle intent. need this:

bundle bundle = new bundle(); bundle.putstring("sms_parameters", smsparameters);   intent notificationintent = new intent(context, carmapactivity.class); notificationintent.putextras(bundle); pendingintent contentintent = pendingintent.getactivity(context, 0,   notificationintent, 0); notifacation.setlatesteventinfo(context, tickertext, message, contentintent); notificationmanager.notify(1, notifacation); 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -