Add buttons above the Notifications tab in the status bar

I am developing an Android application that will work as a service most of the time. The user will be able to control it through the status bar - including the ability to completely stop the service.

Although I can create a custom view and put the buttons in the Notifications area [see fig. 1], I would like it to be indicated above the name "Android" / "Service Provider". In the same way as the Music Player application does (see Figure 2). Thus, even if the user clears their notifications, the application control panel will remain active while the service is running.

What is the best way to do this, please?

Figures 1 and 2

Original image link

+6
android
source share
1 answer

Your ROM has hidden the Ongoing header; both the music player and the equipment control widget use the ONGOING_EVENT flag to stay where they are (someone correct me if I'm wrong). Confirm this by downloading the application to your fixed phone - the documentation specifically indicates, for example. Music players (and other cases when your process is still ongoing in the background) is just when you should use this flag.

You might like to note that the FLAG_NO_CLEAR flag is recommended on the same page - if all you need is to not clear it when the user clicks clear notifications (this is recommended for current applications).

+1
source share

All Articles