android - My Intent.Extras is always null when I click a notification. How can I get the Intent data? -
i'm unable intent's extras data when view notification. following how build notification, , intent data pass it. there wrong it? i've seen other examples similar appeared work.
protected override void onmessage(context context, intent intent) { // irrelevant stuff removed string title = "notification"; string message = "the notification message"; bundle valuesforactivity = new bundle(); valuesforactivity.putint("panelid", (int)panelid); intent pendingintent = new intent(context, typeof (tabcontainer)); pendingintent.putextras(valuesforactivity); pendingintent.setflags(activityflags.singletop); pendingintent.putextra("panelid", (int)panelid); //neither pendingintentflags.cancelcurrent or pendingintentflags.updatecurrent works pendingintent resultpendingintent = pendingintent.getactivity(context, 0, pendingintent, pendingintentflags.cancelcurrent); //pendingintent resultpendingintent = pendingintent.getactivity(context, 0, pendingintent, pendingintentflags.updatecurrent); var builder = new notificationcompat.builder(context); builder.setcontenttitle(title); builder.setautocancel(true); builder.setsmallicon(resource.drawable.icon24); builder.setlargeicon(bitmapfactory.decodestream(context.resources.openrawresource(resource.drawable.icon96))); builder.setcontenttext(message); builder.setcontentintent(resultpendingintent); builder.setticker(title); builder.setvibrate(new long[] { 100, 200, 300 }); var notificationmanager = getsystemservice(context.notificationservice) notificationmanager; notificationmanager.notify(1, builder.build()); }
then in tabcontainer activity, never have data need:
public class tabcontainer : tabactivity { protected override void onresume() { base.onresume(); int panelid = intent.getintextra("panelid", 0); // 0 var extras = intent.extras; // null } }
this worked:
public class tabcontainer : tabactivity { protected override void onnewintent(intent intent) { base.onnewintent(intent); try { var panelid = intent.getintextra("panelid", 0); // things need panelid. } catch (exception ex) { dealwitherror(ex); } } }
Comments
Post a Comment