我写了一个简单的Android应用,它显示了这样的自定义通知:
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);
这段代码在我的应用程序中称为ONCE ONCE,它显示带有进度条的通知(全部正确)。
现在,当用户单击此通知时,我的应用程序将处理该onResume
事件。
public void onResume()
{
super.onResume();
// TODO: Extras è SEMPRE NULL!!! impossibile!
Intent callingintent = getIntent();
Bundle extras = callingintent.getExtras();
但是Extras始终为NULL!
我尝试了以下任何组合:
notificationIntent.putExtra("com.mysecure.lastpage", "SECURECODE");
要么
Bundle extra = new Bundle();
extra.putString(key, value);
notificationIntent.putExtra(extra);
但是getIntent()。getExtras()始终返回NULL。