小编Man*_*anu的帖子

Android主机:与大容量存储USB设备连接

我目前正在尝试开发一个在USB设备上访问xml文件的应用程序.我已阅读有关Android USB Host的Google文档.现在我可以检测到我的USB设备,发现它的规格(如PID/VID),但我无法访问USB设备的文件:(

以下是我查找设备的活动代码:

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);

   }
}
  /* What To Do Now ???? */
Run Code Online (Sandbox Code Playgroud)

我试图在互联网上找到一些例子,但我现在迷路了!:(

任何人都知道如何在USB设备上读取(并最终写入)文件?我听说有一个Mass Storage协议要遵循,但我找不到或理解它!

usb android host

5
推荐指数
1
解决办法
1908
查看次数

标签 统计

android ×1

host ×1

usb ×1