0

I want to hide my app in Notification Bar such as the music player application. When the user presses a button the app should close and display as ongoing in the Notification Bar.

Also how safe is System.exit()?

Sachin Aggarwal
  • 1,095
  • 8
  • 17
pebble
  • 331
  • 2
  • 13

1 Answers1

0

What you are asking for is actually called a Foreground Service.

You can easily find all the documentation about Service and Foreground Service on developer.android.com.

As for quick reference :

Service : Service are android application components which has no user interface and is usually used to carry on background operations. You can read more about android services here.

Foreground Service : These are the just the "subset" of services which perform an operation of which user is continously aware of. These service tend to live for longer duration. You can read more about service here. Since the user has to be continously aware of this service, to this in android, the OS puts a notification related to this service.

So, Now you must be able to see that to "hide app in notification bar", you will have to create a service (so that it runs in the backgournd, and is kind of hidden from what user can see) and mark it as a Foreground Service (so that there is a notification bar associated with the service).

zeekhuge
  • 1,594
  • 1
  • 13
  • 23