paho.mqtt.android
paho.mqtt.android copied to clipboard
disconnect when lock screen
Probably its related to the issue I just posted, try to use a foreground service if you don't already. With the foreground service also if it disconnects then i am able to correctly detect disconnection and reconnect it in foreground.
did you succeed in reconnecting in a foreground service?
Yes, you need to run a foreground service, check in an handler if you are connected to the mqtt client (i use eventbus for communicating between activities and intercept changes), if not connected the connect again.
To let it work you need to deactivate battery optimization otherwise android won't let your app work in foreground.
To let the app work in foreground personally i do use a persistent notification that keeps the app awake until the user stops the task.