Reputation: 205
I'm trying to pass a parameter by notice
private void generateNotification(Context context, String title, String message,int groupid,int count) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Intent intent = new Intent(context,MyActivity.class);
intent.putExtra("group_id",groupid);
Log.d("mylogout","group_id: "+groupid);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setContentIntent(pendingIntent)
.................
.build();
notification.number=count;
notificationManager.notify(groupid, notification);
}
and take it in my Activity
Log.d("mylogout","id from: "+getIntent().getStringExtra("group_id"));
but for some reason the first log writes id = 3 but in MyActivity log writed D/mylogout﹕ id feom main: null
Upvotes: 0
Views: 87
Reputation: 3903
Try this.
getIntent().getIntExtra("group_id", 0);
You are having groupid
as an 'integer' in method parameters.
private void generateNotification(Context context, String title, String message,int groupid,int count)
But trying to get it as a string in your activity will return null.
Upvotes: 2