Wow, thank you! Now I guess I need to look up a tutorial on using the AlarmManager.
On Feb 3, 7:46 am, Mark Murphy <[email protected]> wrote: > On Wed, Feb 2, 2011 at 9:57 PM, Jeffrey <[email protected]> wrote: > > I've got a battery widget I'm working on and I have a broadcast > > receiver for when the battery status changes, but I don't know where > > it needs to go. I tried putting it in the Configuration activity, but > > I keep getting this error: > > > Activity com.android.blah has leaked IntentReceiver com.android.blah > > $2@43758c58 that was originally registered here. Are you missing a > > call to unregisterReceiver()? > > > Please let me know what I'm doing wrong, I'm pretty new to broadcast > > receivers, so if I'm missing something basic please let me know. > > I wouldn't use a broadcast receiver in this case. That would require > you to keep a service running 24x7, to host the receiver, and that is > bad for business. > > Rather, just check the battery level periodically: > > - via updatePeriodMillis in your metadata, or > - via AlarmManager, if the 30-minute minimum for updatePeriodMillis > will be too long (probably would be, in this case) > > To check the battery level, call registerReceiver() with the > ACTION_BATTERY_CHANGED IntentFilter, but a null BroadcastReceiver. The > Intent that is returned to you will be the last-broadcast battery > change Intent, from which you can get the last-known battery level. > > You can even let the user configure the polling period, to balance > between accuracy and battery consumption by the battery app widget. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training in London:http://bit.ly/smand1andhttp://bit.ly/smand2 -- 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

