How to know if the power is connected or not when my application is starting ?
I know, that I can get power state using broadcast receiver with ACTION_POWER_CONECTED and ACTION_POWER_DISCONNECTED but when my app is starting I do not received these Broadcasts.
You don’t actually have to register a receiver when calling
registerReceiver;-). RunIt will return the last intent that has been broadcasted for the given filter. From
ACTION_BATTERY_CHANGED, you can determine whether the phone is on battery or connected to a power source: