I am currently trying to develop an application that accesses xml files on a USB device. I read the Google Documentation about Android Host for Android. Now I can find my USB device, find out its specifications (for example, PID / VID), but I canβt access the files of the USB device :(
Here is my activity code that is looking for devices:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_visu);
affichage = (TextView) findViewById(R.id.afficher);
context = VisuActivity.this.getApplicationContext();
UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
if(deviceList.size()==1){
while(deviceIterator.hasNext()){
device = deviceIterator.next();
}
UsbInterface mUsbInterface = device.getInterface(0);
UsbEndpoint endpoint = mUsbInterface.getEndpoint(0);
UsbDeviceConnection connection = manager.openDevice(device);
}
}
I tried to find some example on the Internet, but now I'm lost !: (
Does anyone know how to make a read (and ultimately) file on a USB device? I heard that there is a Mass Storage protocol, but I do not find it and do not understand!
source
share