what are the power battery performance implications of maintaining a service? Will this drain the battery more to keep a service up and running? Especially if you bind to the service from the widget to call service functions?
On Feb 3, 3:39 pm, Mark Murphy <[email protected]> wrote: > 2011/2/3 Jeffrey <[email protected]>: > > > Thank you, one last issue that I'm having, you said to get the battery > > level to call registerReceiver with a null broadcast receiver, but > > when I try the following code I get a nullpointerexception: > > > int rawlevel = registerReceiver(null, > > batteryLevelFilter).getIntExtra("level", -1); > > > I'm not sure if thats right or not. When I was running a broadcast > > receiver it grabbed the context and the code was as such: > > > int rawlevel = intent.getIntExtra("level", -1); > > > which worked but since I no longer use the broadcast receiver to grab > > the intent I can't seem to figure out how to get it into a manageable > > variable. > > There are two possibilities: > > 1. Your batteryLevelFilter is incorrect > > 2. Your code is being called before an ACTION_BATTERY_CHANGED > broadcast has been sent > > Since #2 is conceivable, depending on when you are setting up your > alarms, be sure to handle a null response to registerReceiver(). > > Also, I would use BatteryManager.EXTRA_LEVEL instead of "level". > That's a change I need to make in one of my own examples, one of these > days... > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training...At Your Office:http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

