Jump to content
Sign in to follow this  
vedat

Foreground service

Recommended Posts

Hello, I want to develop a music player app on fmx. As I understand from the research I must use foreground service to make a persistent menu on the status bar for next/play/pause  musics. Do you have any document or source code that explains the usage of foreground service ? Thanks in advance 

foregroundservice.png

Share this post


Link to post
7 hours ago, vedat said:

As I understand from the research I must use foreground service to make a persistent menu on the status bar for next/play/pause  musics

Can you provide links to the research that shows that is what is required?

Share this post


Link to post
16 hours ago, vedat said:

here is the link

That's information about foreground services. How does "a persistent menu on the status bar for next/play/pause musics" relate to it?

Share this post


Link to post
On 12/4/2021 at 2:22 AM, Dave Nottage said:

That's information about foreground services. How does "a persistent menu on the status bar for next/play/pause musics" relate to it?

Well, if you look at the link https://developer.android.com/guide/components/foreground-services  it says : 

"Examples of apps that would use foreground services include the following:

  • A music player app that plays music in a foreground service. The notification might show the current song that is being played."  As I understand from this document, the notification of the current song can be played/paused or you can switched to next song through that notification bar. Notification bar stays there until the service closes down. Btw thank you for your care

Share this post


Link to post
9 hours ago, vedat said:

A music player app that plays music in a foreground service. The notification might show the current song that is being played

This does not say that the app absolutely has to have a foreground service. The notification can be created without one:
 

https://stackoverflow.com/questions/55324188/how-to-build-a-notification-in-android-and-implement-click-listener

 

Share this post


Link to post
11 hours ago, Dave Nottage said:

This does not say that the app absolutely has to have a foreground service. The notification can be created without one:
 

https://stackoverflow.com/questions/55324188/how-to-build-a-notification-in-android-and-implement-click-listener

 

But I want to show music menu notification bar even if the app was closed. Won't the music menu bar closed once you close your app  if you don't use  something that runs on background ? 

Share this post


Link to post
3 hours ago, vedat said:

even if the app was closed

Yes.. as far as I can ascertain, if the app is closed you would need a service to ensure the notification with the controls is persistent. Here's a problem with this scenario: you will not be able to use TMediaPlayer in a service, since it relies on FMX units, including FMX.Types, because of this issue: https://quality.embarcadero.com/browse/RSP-17857 so you would need to do your own implementation (or find one), avoiding the FMX units.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×