dynamic broadcast receiver for connectivity changes
- by android-dev
I'm trying to register a dynamic broadcast receiver using the following:
BroadcastReceiver connectivityReceiver = new ConnectivityChangeIntentReceiver();
IntentFilter connectivityFilter = new IntentFilter();
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
myApplicationContext.registerReceiver(connectivityReceiver, connectivityFilter);
but I see my ConnectivityChangeIntentReceiver.onReceive method is not called when I turn off Wifi through settings or change to airplane mode.
Has anyone faced a similar problem?
I do not want to statically register the receiver in the Manifest file, as I don't want my app to be started by connectivity changes.