-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Started service vs bound service #559
Comments
P.S. From https://developer.android.com/develop/background-work/services/fg-service-types#data-sync, it seems that Google intends to remove (sooner or later, we'll never know) the |
If you see some improvements, I'm happy to merge it |
Well I was just wondering the rationale. I could test the library without the started service on my app, but that's just one use case. Just so you know, atm after review a bit the code of the library, I've decided not to use the Foreground Service option, since it works well all the same, and I'm removing the authorization for the FOREGROUND_SERVICE_DATA_SYNC in the app manifest. |
With 4.x you don't need any foreground-something as well |
The library is great. Thanks for your effort. I've had the same issue above and Google has rejected my app for production because of the FOREGROUND_SERVICE_DATA_SYNC permission request. I've altered my manifest to remove the permission and everything seems to run happily through Internal Testing on Google Play Console. Hopefully it will get through to production. |
I added this
When you have a better way to solve it, please make a pull request |
Thanks Hannes. Yes, I agree that the permission in the manifest is required to use With the exceptions of systemExempted and shortService foreground service types, apps are only allowed to declare a foreground service permission if the use:
The From what Google requires (see above), I think it will be challenging to get approval from Google to run mqtt in the background. I don't know what the use cases might be for running mqtt when the app is in the background, but if there aren't any, then it would be simple to remove this functionality. It would be nice to hear from anyone who needs to run mqtt in the background and get their thoughts. |
Thank you for the explanation, and what do you recommend now ? |
I had the same problem @craigt543nz and since I didn't need the MQTT service active when the app was off screen, I just removed the permission in the manifest and didn't put a My two cents here is that it should be up to the app developer to decide whether to use it in Foreground or not, and add the permission to the app manifest accordingly. Thus, I think that the solution would be to remove the permission from the library manifest (if that's possible). |
Yes, I agree with you @fabmazz, removing the permission from the library manifest is a better solution. And add a note to the Readme that if you want to use |
First of all, thanks for the library, it's quite good.
However, I'm using this library since a few months, and it has caused me some headaches with the newest version of Android 14. This is because of the issue of foreground services.
I've looked at the code of the library, and it seems you start the service manually, putting it in on foreground when there is a notification, however it's not clear to me why, as you immediately bind the client to the service. From the documentation on bound services, it seems that calling
bindService
is enough on its own to start the service.I'm only asking because for my app, I just need a background way to connect to an MQTT server, and only download data when the user is using the app. Maybe using a foreground service is too much, and by removing the need to call
startService
orstartForeground
, all the library could be simplified.The text was updated successfully, but these errors were encountered: