spyker10 spyker10 - 20 days ago 6
Android Question

how i can intent from notification?

Why is

Intent
from notification null?

Intent resultIntent = new Intent(context, myclass.class);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
Bundle extras=new Bundle();
extras.putString("key","value");
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
context,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.Builder n = new NotificationCompat.Builder(context)
.setContentTitle("test")
.setContentText(text)
.setSound(sound)
.setContentIntent(resultPendingIntent)
.setAutoCancel(true)
.setExtras(extras)
.setSmallIcon(android.R.drawable.ic_media_play);
NotificationManager notificationManager = (NotificationManager) context.getSystemService((context.getApplicationContext().NOTIFICATION_SERVICE));
notificationManager.notify(0, n.build());
}


but in
onStart()
of myclass when i call
getintent().getExtras()
the result is null, why?
how can I
getExtras()
from notification Intent ?

Answer

i think u forgot to call.

resultIntent.putExtras(extras);

before calling it.