0

I need to put a Notification in the Status bar while my app is running, but I don't want it to call back to my Activity if selected. Its meant to just be info to the user that the app is running - basically a reminder in case they press the home button and minimize it.

Ideas?

bursk
  • 1,647
  • 7
  • 25
  • 39
  • Why don't you just ignore the callback? – Falmarri Sep 23 '10 at 17:38
  • I thought that you had to pass in an Intent? Or maybe I'm misunderstanding, how would my Activity not respond to an Intent? – bursk Sep 23 '10 at 17:43
  • possible duplicate of [Android - notification manager, having a notification without an intent](http://stackoverflow.com/questions/7040742/android-notification-manager-having-a-notification-without-an-intent) – Rachel Gallen Apr 22 '13 at 05:49

3 Answers3

1

I have the same desired behavior. My solution was:

Intent intent = new Intent(this, YourActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
mPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);

Also, to make the notification automatically disappear when selected by the user

notification.flags |= Notification.FLAG_AUTO_CANCEL;
paral
  • 51
  • 2
1

Intent intent = new Intent(this, YourActivity.class);

or just

Intent intent = new Intent();

Jeff Bootsholz
  • 2,971
  • 15
  • 70
  • 141
0

I ended up coming up with a solution to this issue although its basically a hack. instead of setting the intent to point to an Activity class I'm using a Dialog class.

this.notificationIntent = new Intent(this, SomeDialog.class);

Now if the user selects the notification, via the logcat, I can see the Starting Activity logged, but it appears nothing happens.

This allows me to post a notification that stays while my app is running and then I just dismiss it when the user exits.

bursk
  • 1,647
  • 7
  • 25
  • 39
  • Does not this : http://stackoverflow.com/questions/7040742/android-notification-manager-having-a-notification-without-an-intent work for you ? Basically `new Intent()` – Mr_and_Mrs_D Jul 21 '13 at 00:47