仅当手机锁定时,本机NFC阅读器才启用

时间:2019-03-20 16:54:06

标签: android react-native react-native-android nfc

我正在使用react-native-rfid-nfc-scanner软件包进行NFC读取。

我已经完成了模块的简单初始化,并添加了一个侦听器。

import {NfcRfidScanner} from "react-native-rfid-nfc-scanner";
const scanner = new NfcRfidScanner();
scanner.init();
var listenerCallback = function(x) { console.log('listener:', x); };
var errorCallback = function(e) { console.log('error:', e); };
scanner.addListener('scanningListener', listenerCallback, errorCallback);
console.log('scanner enabled?', scanner.isEnabled());
console.log('device can use scanner??', scanner.getStatus());

当我在连接USB的android设备上打开应用程序后,会看到以下控制台输出:

scanner enabled? false
ReactFabric-prod.js:7003 device can use scanner?? waiting
ReactNativeRenderer-dev.js:14808 Running application "NativeScannerApp" with appParams: {"rootTag":31}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF

当我在设备上锁定屏幕,然后保存对文件的更改,并通过watchman启动重新加载时,我发现这是通过控制台实现的:

scanner enabled? true
VM33:62 device can use scanner?? ready
index.js:2277 [React Transform HMR] Patching App

当手机解锁时,为什么NFC阅读器无法启用?我该如何解决?

0 个答案:

没有答案