Detecting the device being plugged in

Apparently the ACTION_BATTERY_CHANGED is a “sticky broadcast” which means you can register for it and receive it any time after it has been broadcast. To get the plugged state you can do something like: public void onCreate() { BroadcastReceiver receiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, … Read more