How to detect an external device in android

I want to write a program to detect any external device that my Android phone is connected to. For example, if I connect to a computer for sharing with usb mass storage or if I connect for charging.

Which API or package in android is responsible for hardware interfaces. How can I detect any external device if it is connected to my Android phone.

+3
source share
2 answers

While a USB connection is not completely synonymous with external power, this may be the smartest way to detect it for most devices using older versions.

ACTION_BATTERY_CHANGED Intent BATTERY_PLUGGED_USB BATTERY_PLUGGED_AC.

.

http://developer.android.com/reference/android/os/BatteryManager.html

USB-, , USB, Android USB- .

0

, 2.3.4 3.1 USB API.

0

All Articles