在Android9测试取得sd卡或usb
private List<StorageVolume> localDevicesList;
StorageManager manager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
localDevicesList = manager.getStorageVolumes();
StorageVolume storageVolume;
int deviceCount = localDevicesList.size();
//putLog("usb","localDevicesList:"+deviceCount);
List strList = new ArrayList();
for (int i = 1; i < localDevicesList.size(); i++) {
storageVolume = localDevicesList.get(i);
//通过这个getDescription 获取的描述区分
String devecitype = storageVolume.getDescription(context).toString();
putLog("usb","getUuid:"+storageVolume.getUuid());
putLog("usb","getDescription:"+devecitype);
//putLog("usb","storageVolume.toString:"+storageVolume.toString());
strList.add(devecitype);
if(Intent.ACTION_MEDIA_MOUNTED.equals(action)){
if (devecitype.contains("Tarjeta SD")) {
//putLog("usb","sdcard:"+devecitype);
img_status_SDCard.setVisibility(View.VISIBLE);
}else if(storageVolume.getUuid()!=null){
//putLog("usb","usb:"+devecitype);
img_status_usb.setVisibility(View.VISIBLE);
}
}
}