Öffnungsaktivität nach dem Klicken auf Push-Benachrichtigung Android

Ich bin ein großer Neuling in der Android-Programmierung, also tut mir leid, wenn dies eine einfache Aufgabe ist. Ich habe das Vogella-Lernprogramm für Push-Benachrichtigungen (http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html) ziemlich genau befolgt. Ich habe einige andere Stapelüberlauf-Fragen gelesen, bin jedoch ein wenig verwirrt darüber, wie ich eine Absicht öffnen soll, sobald ich die Benachrichtigung erhalte.

Wenn ich zum Beispiel nur wollte, dass die Benachrichtigung mich zu einer Website führt, wie würde das funktionieren? Müsste es zusammen unter meine MessageReceivedActivity oder ein anderes Projekt / eine andere Klasse gehen?

Vielen Dank

Hier ist der Code, den ich für meinen C2DMMessageReceiver habe

<code>@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.w("C2DM", "Message Receiver called");
    if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
        Log.w("C2DM", "Received message");
        final String payload = intent.getStringExtra("payload");
        Log.d("C2DM", "dmControl: payload = " + payload);
        // TODO Send this to my application server to get the real data
        // Lets make something visible to show that we received the message
        createNotification(context, payload);

    }
}

public void createNotification(Context context, String payload) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.ic_launcher,
            "Message received", System.currentTimeMillis());
    // Hide the notification after its selected
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    //adding LED lights to notification
    notification.defaults |= Notification.DEFAULT_LIGHTS;

    Intent intent = new Intent(context, MessageReceivedActivity.class);
    intent.putExtra("payload", payload);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            intent, 0);
    notification.setLatestEventInfo(context, "Message",
            "New message received", pendingIntent);
    notificationManager.notify(0, notification);

}
</code>

}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage