我正在尝试使用我的 OTG 电缆通过 USB 主机访问我的 DSLR 上的 SD 卡。我相信这是通过 PTP 实现的。我见过几个应用程序也可以在没有 root 权限的情况下执行此操作,他们不仅可以访问它,还可以控制快门速度和其他东西。但我只对访问 DSLR 上的 SD 卡感兴趣。连接到 USB 设备后我卡住了。见附件代码
private void checkInfo() {
manager = (UsbManager) getSystemService(Context.USB_SERVICE);
/*
* this block required if you need to communicate to USB devices it's
* take permission to device
* if you want than you can set this to which device you want to communicate
*/
// ------------------------------------------------------------------
mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(
ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
registerReceiver(mUsbReceiver, filter);
// -------------------------------------------------------------------
HashMap<String , UsbDevice> deviceList = manager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
String i = "";
while (deviceIterator.hasNext()) {
device = deviceIterator.next();
manager.requestPermission(device, mPermissionIntent);
i += "\n" + "DeviceID: " + device.getDeviceId() + "\n"
+ "DeviceName: " + device.getDeviceName() + "\n"
+ "DeviceClass: " + device.getDeviceClass() + " - "
+ "DeviceSubClass: " + device.getDeviceSubclass() + "\n"
+ "VendorID: " + device.getVendorId() + "\n"
+ "ProductID: " + device.getProductId() + "\n";
}
textInfo.setText(i);
}
有人可以告诉我如何阅读然后最终将照片从 DSLR 的 SD 卡下载到我的 android 应用程序。
更新
所以我尝试了这个库https://github.com/mjdev/libaums
它很棒,但问题是它只支持 USB 大容量存储。它不会识别我的相机存储。
任何帮助表示赞赏。