I have a broadcast receiver in my program to get react to the battery level like so:
private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
Please be aware, that the intent you get from registerReceiver call
Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
can be null. So please make a check before using the intent, e.g.
if(intent != null){
// do your stuff here...
}
I just got a null pointer exception, causing the app to crash!