如何检测可用于存储的已安装设备(如Pen-Drive)?如何找到安装的存储设备的路径,以便我可以从中读取文件?USBdevice识别为存储设备并找到路径
我用下面取权限访问安装器件广播接收机:
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (ACTION_USB_PERMISSION.equals(action)) {
synchronized (this) {
UsbDevice device = (UsbDevice) intent
.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (intent.getBooleanExtra(
UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
if (device != null) {
// call method to set up device communication
Log.d(TAG, "onReceive: "+intent.getExtras().toString());
Log.d(TAG, "onReceive: "+intent.getData());
LinearLayout layoutUsbList = (LinearLayout)findViewByI