I wrote a simple Android application that shows a custom notification:
Context context = getApplicationContext(); NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification( R.drawable.icon, title, System.currentTimeMillis()); Intent notificationIntent = new Intent( context, this.getClass()); notificationIntent.putExtra("com.mysecure.lastpage", "SECURECODE"); PendingIntent pendingIntent = PendingIntent.getActivity( context , 0, notificationIntent, 0); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT; notification.contentView = new RemoteViews(context.getPackageName(), R.layout.notifypbar); notification.contentIntent = pendingIntent; notification.contentView.setTextViewText(R.id.notifypb_status_text, text); notification.contentView.setProgressBar(R.id.notifypb_status_progress, 100, (int)(100*progress), false); manager.notify(104, notification);
This part of the code is called ONLY ONE in my application and displays a notification with a progress bar (everything is correct).
Now, when the user clicks on this notification, my application is handling the onResume event.
public void onResume() { super.onResume();
but additional functions are always NULL!
I tried any combination:
notificationIntent.putExtra("com.mysecure.lastpage", "SECURECODE");
or
Bundle extra = new Bundle(); extra.putString(key, value); notificationIntent.putExtra(extra);
but getIntent (). getExtras () always returns NULL.
android android-intent notifications
Magius Jun 15 '11 at 2:15 2011-06-15 02:15
source share