将指纹扫描仪/ zk9500 /连接到平板电脑时,无需征求许可

时间:2019-04-12 07:08:52

标签: android sdk fingerprint biometrics zkteco

我第一次使用此指纹扫描仪/ zk9500 /。我编译jar文件。

implementation files('libs/zkandroidcore.jar')
implementation files('libs/zkandroidfpreader.jar') 

所以我写这段代码。

 private BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (ACTION_USB_PERMISSION.equals(action)) {
                synchronized (this) {
                    if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
                        LogHelper.i("have permission!");
                    } else {
                        LogHelper.e("not permission!");
                    }
                }
            }
        }
    };

    private void InitDevice() {
        UsbManager musbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_USB_PERMISSION);
        filter.addAction(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
        Context context = this.getApplicationContext();
        context.registerReceiver(mUsbReceiver, filter);

        for (UsbDevice device : musbManager.getDeviceList().values()) {
            if (device.getVendorId() == VID && device.getProductId() == PID) {
                if (!musbManager.hasPermission(device)) {
                    Intent intent = new Intent(ACTION_USB_PERMISSION);
                    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
                    musbManager.requestPermission(device, pendingIntent);
                }
            }
        }
    }

但不征求许可。我不知道如何寻求许可。

1 个答案:

答案 0 :(得分:0)

只有“危险”权限需要运行时确认。 presenceOf(mode_1_i)==presenceOf(mode_2_i)并不危险。

危险权限列表:https://developer.android.com/guide/topics/permissions/overview.html#permission-groups