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

disconnect when lock screen #408

Open
moo611 opened this issue Dec 8, 2022 · 3 comments
Open

disconnect when lock screen #408

moo611 opened this issue Dec 8, 2022 · 3 comments

Comments

@moo611
Copy link

moo611 commented Dec 8, 2022

No description provided.

@augelloantonio
Copy link

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.

@moo611
Copy link
Author

moo611 commented Dec 22, 2022

did you succeed in reconnecting in a foreground service?

@augelloantonio
Copy link

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.

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