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.

9
задан Ran 11 September 2010 в 15:39
поделиться