android - How to bring application to front when the notification icon is clicked (from Service)? -
i have application plays media of service. runs smoothly of service ( ongoing notification created ). when key pressed application goes background. problem when click notification icon new instance of application created every time. how can application background front of notification bar?
my notification looks this:
private void notifyme() { final notificationmanager mgr = (notificationmanager) getsystemservice(notification_service); notification note = new notification(r.drawable.icon_audio, "online!", system.currenttimemillis()); note.flags = notification.flag_ongoing_event; pendingintent = pendingintent.getactivity(this, 0, new intent(this, playmedia.class), 0); note.setlatesteventinfo(this, "media payer", "online",i); mgr.notify(notify_me_id, note); } the solution got work adding following line in manifest file: android:launchmode="singleinstance" intent flag didn't have effect, thought odd...
the intent pass pendingintent.getactivity needs have appropriate flag set bring running application front. so:
intent startactivity = new intent(this,playmedia.class ); startactivity.setflags(intent.*appropriate flag*); pendingintent = pendingintent.getactivity(this, 0, startactivity, 0); go http://developer.android.com/reference/android/content/intent.html , search (ctrl+f) "flag_". there find list of flags can use.
Comments
Post a Comment