我已经让 BarcodeScanner 在 PhoneGap 2.4 - Android 中工作。
它很好地扫描了 qrcode,但没有响应返回给 JavaScript 中的回调。
我在 Eclipse 日志中得到以下信息:
08-06 00:50:13.910: D/dalvikvm(14608): GC_CONCURRENT freed 21K, 16% free 6889K/8199K, paused 12ms+13ms, total 59ms
08-06 00:50:13.980: D/dalvikvm(14608): GC_FOR_ALLOC freed 533K, 22% free 6458K/8199K, paused 25ms, total 25ms
08-06 00:50:14.030: D/dalvikvm(14608): GC_CONCURRENT freed 34K, 16% free 6889K/8199K, paused 12ms+4ms, total 50ms
08-06 00:50:14.030: D/dalvikvm(14608): WAIT_FOR_CONCURRENT_GC blocked 13ms
08-06 00:50:14.050: D/DecodeHandler(14608): Found barcode in 55 ms
08-06 00:50:14.070: D/dalvikvm(14608): GC_FOR_ALLOC freed 92K, 13% free 7175K/8199K, paused 22ms, total 22ms
08-06 00:50:14.090: D/CaptureActivityHandler(14608): Got decode succeeded message
08-06 00:50:16.060: D/CaptureActivityHandler(14608): Got return scan result message
08-06 00:50:16.180: D/DroidGap(14608): Incoming Result
08-06 00:50:16.180: D/DroidGap(14608): Request code = 195543262
08-06 00:50:16.180: D/DroidGap(14608): We have a callback to send this result to
08-06 00:50:16.180: D/DroidGap(14608): Resuming the App
我使用默认 JS 来触发扫描,用于测试目的:
var scanCode = function() {
window.plugins.barcodeScanner.scan(
function(result) {
alert("Scanned Code: " + result.text
+ ". Format: " + result.format
+ ". Cancelled: " + result.cancelled);
}, function(error) {
alert("Scan failed: " + error);
});
}
我想知道你们中是否有人以前听说过这个问题,或者知道从哪里开始寻找可能的原因?
它与应用程序的暂停和恢复有关吗?
还有其他建议吗?