使用模拟器CordovaSim或Ionic VIEw应用程序不会出现此问题,只有在为Android构建项目时才出现.
出现问题时,条形码读取器需要读取DATA_MATRIX代码两次,以返回到应用程序.
$cordova -v5.2.0 $cordova platform lsandroID 4.1.1$cordova plugin lscordova-plugin-barcodescanner 0.7.0 "barcodeScanner"
我的config.xml的一部分:
<feature name="barcodeScanner"> <param name="androID-package" value="com.phonegap.plugins.barcodescanner.barcodeScanner" /> <param name="wp-package" value="barcodeScanner" /> <param name="ID" value="cordova-plugin-barcodescanner" /></feature>
条形码读取器的控制器:
angular.module('starter.controllers', []).controller('ScanCtrl', function($scope, $http, $ionicPopup) {$scope.message = '';$scope.click = function() { console.log("apertura scanner"); $scope.message = ''; cordova.plugins.barcodeScanner.scan( function (result) { if(result.cancelled == false){ if(result.format == "DATA_MATRIX"){ var JsonToSend = result.text; valIDate(JsonToSend); } else { console.log("formato codice a barre non riconosciuto"); } }else{ console.log("lettura annullata"); } }, function (error) { alert("Errore scansione: " + error); } );}$scope.clear = function() { $scope.message = '';}valIDate = function(textJsON){ console.log(textJsON); $http.post('http://www.esempio.con', textJsON). then(function(response) { console.log("success"); console.log(angular.toJson(response)); $scope.data = response.data.response; //alert(response.data.response); if(response.data.response == true){ showAlert(true); $scope.message = '<img src="img/success.png" alt="" /><p>non valIDa</p>'; }else{ showAlert(false); $scope.message = '<img src="img/error.png" alt="" /><p>non valIDa</p>'; } }, function(response) { $scope.data = "errore " + response.status + " " +response.statusText; console.error(response.status); console.error(response.statusText); });}// An alert dialogshowAlert = function(response) { if(response == true){ var alertPopup = $ionicPopup.alert({ Title: "Risultato", templateUrl: 'templates/popupTrue.HTML', scope: $scope, CSSClass: 'resultPopup', okText: 'Chiudi' }); } else { var alertPopup = $ionicPopup.alert({ Title: "Risultato", templateUrl: 'templates/popupFalse.HTML', scope: $scope, CSSClass: 'resultPopup', okText: 'Chiudi' }); } alertPopup.then(function(res) { console.log('alert mostrato'); });}})
视图的一部分:
<ion-slIDe ng-controller="ScanCtrl"> <div > <h2>Scansione</h2> <div> <button ng-click="click()"> Avvia Scansione </button> </div> <div ng-bind-HTML="message"></div> <div ng-show="message.length!=0"> <button ng-click="clear()"> Pulisci Risultato </button> </div> </div> </ion-slIDe>
解决方法:
我没有使用失去触摸效果的data-tap-Disabled =“ true”,而是通过使用触摸而不是ng-click使其工作了.我不知道为什么.
<button on-touch="click()"> Avvia Scansione</button>
总结 以上是内存溢出为你收集整理的科尔多瓦条码扫描器在Android中打开两次全部内容,希望文章能够帮你解决科尔多瓦条码扫描器在Android中打开两次所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)