I was wondering if would be possible to perform an action for each time the USB status of the device changes.
For example if the user plugs in the cable and it is in sync/charge mode it performs a certain action, if the user then changes the phone into USB Memory Card mode another action is performed and if the user then disconnects the cable then the another action is done.
Is this actually possible?
Is this actually possible.
Sure.
Android broadcasts various Intents that you can listen to with a BroadcastReceiver. Among these are:
ACTION_BATTERY_CHANGED (tells you if device is plugged into USB or AC)ACTION_UMS_CONNECTED and ACTION_UMS_DISCONNECTED (tells you if device enters or leaves USB Mass Storage mode)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With