tags:

views:

31

answers:

1

How can I resume my activity when a notification in the statusbar is clicked?

This is the code I have, it shows the notification but when you click it nothing happens:

public void showNotification(){

          myNotificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

          CharSequence NotificationTicket = "Notification";
          CharSequence NotificationTitle = "Notification";
          CharSequence NotificationContent = "Test"
          long when = System.currentTimeMillis();

          Notification notification =
           new Notification(R.drawable.status_icon, NotificationTicket, when);

          Context context = getApplicationContext();

          Intent notificationIntent = new Intent(this,bgPlayer.class);
          PendingIntent contentIntent =
           PendingIntent.getActivity(this, 0, notificationIntent, 0);

          notification.setLatestEventInfo(context, NotificationTitle,
            NotificationContent, contentIntent);

          myNotificationManager.notify(NOTIFICATION_ID, notification);
    }
A: 

See the answer in my question:

http://stackoverflow.com/questions/3378193/android-how-to-avoid-that-clicking-on-a-notification-calls-oncreate

This answer explains how to resume your activity.

Roflcoptr
Great! Thanks :)
JouiCK