Skip to content
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

why is android O devices needs to be set as foreground service? #278

Closed
Ganime422 opened this issue Jan 27, 2022 · 4 comments
Closed

why is android O devices needs to be set as foreground service? #278

Ganime422 opened this issue Jan 27, 2022 · 4 comments

Comments

@Ganime422
Copy link

Hello

I want to use this lib instead this one:
https://github.com/eclipse/paho.mqtt.android
because I had the Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. error.

In here I saw that it is needed to add this line for android O devices:

val client = MqttAndroidClient(context, uri, clientId).apply {
    setForegroundService(foregroundNotification, 3)
}
  1. why is this needed? what is the foregraound service means and do I need to do any other refactroing to my code except for this?
  2. what is the foregroundNotification variable? I don't use anything like it curently

thanks!

@Ganime422
Copy link
Author

I don't mind use it as a foregroun service if it's needed
but I currently don't know what to put inside this foregroundNotification since I don't use it in my app.
what should I put inside of it or can I just put null?

@hannesa2
Copy link
Owner

Please have a look in the code. It's a running sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants