android - Connectivity Change Receiver survives/starts after boot? -
i have simple broadcast receiver listens in connectivity changes , if network available, set recurring alarm start short-lived service. if there no network connection, disable recurring alarm:
public class connectivitychange extends broadcastreceiver { @override public void onreceive(context context, intent intent) { log.d(getclass().getname(), "connectivity changed! :/"); myapplication app = (myapplication ) context .getapplicationcontext(); if (app.isconnected()) { // setup repeating alarms, since connected. app.setcurrencyratesservicerepeatingalarm(context); log.d(getclass().getname(), "connected :d"); } else { // cancel repeating alarm, since not connected. app.unsetcurrencyratesservicerepeatingalarm(context); log.d(getclass().getname(), "not connected :("); } } } the manifest looks like:
<receiver android:name="connectivitychange"> <intent-filter> <action android:name="android.net.conn.connectivity_change"/> </intent-filter> </receiver> all of works fine.
however, code seem run after reboot emulator. i'm not asking boot_complete. made sure didn't restore emulator snapshot. expected behavior? i'm not sure documented. ask boot_complete when came across this.
i know old question, thought i'd weigh in anyway. it's quite possible connectivity changes whenever boot, example device goes no connection connection. therefore code run everytime device boots.
Comments
Post a Comment