getting battery level at android widget
I wrote a widget for Android and I'm trying to get the battery level. I've tried using Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); but I get the error: "IntentReceiver components are not allowed to register to receive intents" Why? the ACTION_BATTERY_CHANGED is a sticky intent and I don't register a receiver (null in the first parameter). Any workaround? Thanks. hackbod gave the solution at the comments: " use getApplicationContext().registerReciever() " Ummmm...that feels like a bug. They must be doing the is-a- BroadcastRecevier