getIntent () Extras always NULL

Я написал простое приложение для 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);

Этот фрагмент кода вызывается ТОЛЬКО ОДИН РАЗ в моем приложении, и он отображает уведомление с индикатором выполнения (все правильно).

Теперь, когда пользователь нажимает на это уведомление, мое приложение обрабатывает 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.

74
задан Michael Currie 7 September 2015 в 20:40
поделиться