What happens if I don't unregister a receiver? Will it slow down my app or causes app crash or throws some sort of exception? I need this receiver to be reigstered all time, even if app is closed:
this.registerReceiver(broadcastReceiver, new IntentFilter(
PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
It depends:
If you don't do that when it was registered in an Activity (by manifest), Android OS will report
leaked broadcast service error
.But if the BroadcastReceiver is dynamically registered by the Service, it will not be leaked if you make sure it is unregistered when the Service is destroyed.
If it was killed by system and you register it again it will
update the previous one
.