I have developed a Flutter app that collects cell signal strength data using native Java code and sends it over MQTT in real time for monitoring and testing purposes. The app also integrates location data, so I used the location library to enable background execution.
However, I am facing an issue: when the app is minimized or goes to the background, I stop receiving any data from the native code.
Here’s what I’ve tried so far:
Event Channel: I implemented an event channel to stream data from the native code. It works perfectly when the app is in the foreground, with the UI updating as expected. However, it stops working once the app goes into the background.
Method Channel Backup: I tried periodically calling a method channel as a fallback to the event channel, but this approach also didn’t work in the background.
Does anyone have insights into why this might be happening? Are there better approaches to ensure continuous data collection in the background? Any pointers or suggestions are highly appreciated!
I already tried to use flutter_background_service library without success.
I added a periodic method channel call as a backup.
I run the app in S23 ultra and S21 ultra both with android 14. The problem occurs only in S23 ultra.
Wreck-b Autitore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.