I'm declaring a broadcastReceiver in my AppWidgetProvider onUpdate() method. The broadcast receiver would listen to connectivity changes.
IntentFilter intentFilter = new IntentFilter(connectivityChange);
context.getApplicationContext().registerReceiver(mReceiver, intentFilter);
Does a new broadcastReceiver get created every time my onUpdate() method launches?
If so, how do I unregister the previous broadcast, so that I don't have dozens of broadcastReceivers?
context.getApplicationContext().unregisterReceiver(mReceiver);
does not work, as the AppWidgetProvider loses the instance of the mReceiver.
EDIT: I cannot declare the receiver in the manifest, as the connectivity change action was disabled in the manifest for the most recent Android API levels, so i have to register it programatically