Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why my widget broadcast receiver service stops when the main app stops

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?

like image 680
narb Avatar asked Nov 08 '22 05:11

narb


1 Answers

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

like image 136
Nazarii Moshenskiy Avatar answered Nov 27 '22 06:11

Nazarii Moshenskiy