使用 ngCordova 和 Ionic 时,条码扫描器无法在 Android 上工作
Barcode Scanner not working on Android when using ngCordova and Ionic
到目前为止,该应用程序只是一个按钮,可以打开条码扫描器并在 returns 时显示结果,非常简单。但是,当您按下按钮时,会出现以下屏幕:http://i.imgur.com/2XOPLvU.png?1
重新启动我的设备没有任何区别。相机可与其他需要使用相机的应用程序配合使用。
控制器代码如下:
QRKeeper.controller('ScannerController', function($scope, $cordovaBarcodeScanner){
//Function that runs the scanner
$scope.scanCode = function(){
console.log("Scan button pressed");
$cordovaBarcodeScanner.scan()
.then(
function(response){
if(!response.cancelled){
console.log("Scan successful");
} else {
console.log("Scan cancelled");
}
}, function(error){
console.log("Error when trying to read code");
}
);
}
});
按照 Ionic 网站上的建议将其包装在 deviceready
中没有任何区别。执行时,chrome://inspect
没有显示任何错误日志。
谢谢!
我正在使用这个条码扫描仪https://github.com/phonegap/phonegap-plugin-barcodescanner
使用 ngCordova 插件http://ngcordova.com/docs/plugins/barcodeScanner/
有人最终制作了一个解决问题的插件 here on Github。我最终删除了插件并添加了这个插件:
https://github.com/jrontend/phonegap-plugin-barcodescanner
我找不到确切的错误是什么,我只是发现它与 Android 在较新版本中请求应用程序权限的方式有关。
到目前为止,该应用程序只是一个按钮,可以打开条码扫描器并在 returns 时显示结果,非常简单。但是,当您按下按钮时,会出现以下屏幕:http://i.imgur.com/2XOPLvU.png?1
重新启动我的设备没有任何区别。相机可与其他需要使用相机的应用程序配合使用。
控制器代码如下:
QRKeeper.controller('ScannerController', function($scope, $cordovaBarcodeScanner){
//Function that runs the scanner
$scope.scanCode = function(){
console.log("Scan button pressed");
$cordovaBarcodeScanner.scan()
.then(
function(response){
if(!response.cancelled){
console.log("Scan successful");
} else {
console.log("Scan cancelled");
}
}, function(error){
console.log("Error when trying to read code");
}
);
}
});
按照 Ionic 网站上的建议将其包装在 deviceready
中没有任何区别。执行时,chrome://inspect
没有显示任何错误日志。
谢谢!
我正在使用这个条码扫描仪https://github.com/phonegap/phonegap-plugin-barcodescanner
使用 ngCordova 插件http://ngcordova.com/docs/plugins/barcodeScanner/
有人最终制作了一个解决问题的插件 here on Github。我最终删除了插件并添加了这个插件:
https://github.com/jrontend/phonegap-plugin-barcodescanner
我找不到确切的错误是什么,我只是发现它与 Android 在较新版本中请求应用程序权限的方式有关。