Search code examples
javaandroidandroid-activity

Display image on screen while charging on Android


I am writing an Android application that should display the specific image (Bitmap) while the user is charging his phone.

The life-cycle:

  1. User installs my application.
  2. User does not have to run my application.
  3. When user connects the charger (usb to PC or just an charger), my application automatically starts and show the image on the screen (during charging).
  4. User stops charging the phone, my application hides the image.

How could I achieve it?


Solution

  • If i remember correctly you can get the "ACTION_POWER_CONNECTED" event with a BroadcastReceiver to do whatever you want. Just Google, there are pretty good tutorials ;)