I do something like this

private static BroadcastReceiver batteryInfo = new BroadcastReceiver()
{
 @Override
 public void onReceive(Context context, Intent intent) {
  String action = intent.getAction();
  if(Intent.ACTION_BATTERY_CHANGED.equals(action)) {
   int level = intent.getIntExtra("level", 0);
   int scale = intent.getIntExtra("scale", 100);
   int plugged = intent.getIntExtra("plugged", 0);
   int batteryLevel = level * 100 / scale;
   .
   .
   .
  }
 }
}

the value of 'plugged' indicates whether the phone is on charge or
not. Normally a 2 indicates that the phone is on charge.

Regards

On Mar 8, 5:31 pm, Paul <paulcalvinkenn...@gmail.com> wrote:
> What is the event that tells me when the Android device is hooked up
> to a power plug?  I need to know what to monitor to know when the
> system goes from battery to charging and vice versa.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to