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?
Sure.
Android broadcasts various
Intentsthat you can listen to with aBroadcastReceiver. Among these are:ACTION_BATTERY_CHANGED(tells you if device is plugged into USB or AC)ACTION_UMS_CONNECTEDandACTION_UMS_DISCONNECTED(tells you if device enters or leaves USB Mass Storage mode)