I have a widget that implements a specific broadcast receiver service to detect when the wifi connection goes down.
It works perfectly if the main activity is running or not.
The issue I have is when I stop the main activity then the broadcast receiver service stops as I don't detect anymore the wifi changes.
Is there a way to startservice that survives the main activity?
if not, any other mechanisms?
2 Answers
Answers 1
Probably you need to register your receiver in manifest and mark it as exported=true
, so it can work if the app is not running. Check this link for detailed info please https://developer.android.com/guide/components/broadcasts
Answers 2
Why have I been down voted?
I've found a workaround: Broadcast Receivers started in an alarm manager are not stopped (when the main activity stops) in O. So I start an AM with a high repeatin interval.
0 comments:
Post a Comment