Java android如何检查usbDevice requestUserPermission是否过大

时间:2019-02-18 13:10:32

标签: java android

如何确定许可是否被授予,我找到了一个像这样的串行端口设备:

private void findSerialPortDevice() {

    HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
    HashMap<String, UsbDevice> usbDevices1 = new HashMap<String, UsbDevice>();
    usbDevices1.clear();

    if (!usbDevices.isEmpty()) {
        boolean keep = true;
        for (Map.Entry<String, UsbDevice> entry : usbDevices.entrySet()) {
            device = entry.getValue();
            int deviceVID = device.getVendorId();
            int devicePID = device.getProductId();

            if (deviceVID == 1659 && devicePID == 8963) {
                requestUserPermission();

                keep = false;

                if (!keep)
                    break;
            }
        }

        if (!keep) {
            Intent intent = new Intent(ACTION_NO_USB);
            sendBroadcast(intent);
        }
    } else {
        Intent intent = new Intent(ACTION_NO_USB);
        sendBroadcast(intent);
    }
}

0 个答案:

没有答案