Comment faire pour déterminer si l'Application Android ouvert à compter de la Notification de message?

En général, quand j'ai le message de notification sur la barre de notification et cliquez sur elle. Ouvrir le régime enregistré d'Application pour ce message.

Au Démarrage de l'Activité, la Façon de déterminer si l'Application est ouverte à partir d'elle?

et plus mieux, c'est Comment récupérer la notification de l'id sur le OnCreate() la méthode?

Mise à jour: à partir de @Ovidiu - voici mon code pour putExtra de pousser

       Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
       notification.contentView = contentView;

       Intent notificationIntent = new Intent(this, Startup.class);
       notificationIntent.putExtra("JOBID", jobId);

       PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);

       notification.flags = Notification.FLAG_AUTO_CANCEL;
       notification.contentIntent = contentIntent;


       mNotificationManager.notify(jobId, notification);

et sur les Activités Principales "Startup.java" le code est

    Intent intent = this.getIntent();
    if (intent != null && intent.getExtras() != null && intent.getExtras().containsKey("JOBID")) {
        int jobID = this.getIntent().getExtras().getInt("JOBID");

        if (jobID > 0) {

        }
    }

intention.getExtras() retourne toujours null. Tourner, j'ai besoin de passer PendingIntent.FLAG_ONE_SHOT . Il est maintenant passé le long!!

  • "besoin de passer PendingIntent.FLAG_ONE_SHOT" - a été vraiment utile. Mais vous avez besoin de vérifier une autre chose - si cette Activité est venue de l'histoire. Vérifier ma réponse ci-dessous.
  • FLAG_ONE_SHOT entraîne l'application à être lancé qu'une seule fois lorsque vous cliquez sur la notification, ce qui pourrait ne pas être ce que vous voulez dans le cas d'un collant de notification à partir d'un service d'arrière-plan. Dans cette situation, FLAG_UPDATE_CURRENT a fonctionné pour moi.
InformationsquelleAutor Jirapong | 2011-09-09