How do I know if USB is connected to an Android device?

I wrote an Android application and I would like the application to know when the Android device is connected to the PC via USB or even better, find out when it is connected and adc logcat is working. Is it possible?

My goal is to write traces to a separate circular buffer (which is sometimes written to an SD card), unless the device is connected, for example, via Eclipse and logcat - in this case I would like to display traces as part of logcat as they arise.

+3
source share
1 answer

According to the Intent doc, you have several intentions related to USB storage:

ACTION_MEDIA_SHARED
Broadcast Action: , USB.

ACTION_UMS_CONNECTED
Broadcast Action: USB Mass Storage.

ACTION_UMS_DISCONNECTED Broadcast Action: USB Mass Storage.

, , USB.

, .

+3

Source: https://habr.com/ru/post/1759594/


All Articles