使用模拟器 CordovaSim 或 Ionic View 应用程序时不会出现此问题,但只有在为 Android 构建项目时才会出现此问题。 当问题出现时,条形码阅读器需要读取 DATA_MATRIX 代码两次才能返回到应用程序。
$cordova -v
5.2.0
$cordova platform ls
android 4.1.1
$cordova plugin ls
cordova-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>
条形码阅读器的 Controller :
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 dialog
showAlert = 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');
});
}
})
部分 View :
<ion-slide ng-controller="ScanCtrl">
<div class="contenuto">
<h2>Scansione</h2>
<div>
<button style="border-radius:7px; margin-left:auto; margin-right: auto;" class="button button-large icon-left ion-ios-barcode-outline" ng-click="click()">
Avvia Scansione
</button>
</div>
<div style="margin-top: 5px;" ng-bind-html="message"></div>
<div style="margin-top: 5px;" ng-show="message.length!=0">
<button style="border-radius: 7px;margin-left:auto; margin-right: auto;" class="button button-large icon-left ion-trash-b" ng-click="clear()">
Pulisci Risultato
</button>
</div>
</div>
</ion-slide>
最佳答案
我没有使用失去 UI 触摸效果的 data-tap-disabled="true",而是通过使用 on-touch 而不是 ng-click 来让它工作。虽然我不知道为什么。
<button on-touch="click()">
Avvia Scansione
</button>
关于android - Cordova,条码扫描器在 Android 中打开两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32336683/
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我写了一个非常简单的rake任务来尝试找到这个问题的根源。namespace:foodotaskbar::environmentdoputs'RUNNING'endend当在控制台中执行rakefoo:bar时,输出为:RUNNINGRUNNING当我执行任何rake任务时会发生这种情况。有没有人遇到过这样的事情?编辑上面的rake任务就是写在那个.rake文件中的所有内容。这是当前正在使用的Rakefile。requireFile.expand_path('../config/application',__FILE__)OurApp::Application.load_tasks这里
我有这个代码File.open(file_name,'r'){|file|file.read}但是Rubocop发出警告:Offenses:Style/SymbolProc:Pass&:readasargumenttoopeninsteadofablock.你是怎么做到的? 最佳答案 我刚刚创建了一个名为“t.txt”的文件,其中包含“Hello,World\n”。我们可以按如下方式阅读。File.open('t.txt','r',&:read)#=>"Hello,World\n"顺便说一下,由于第二个参数的默认值是'r',所以这样
我正在为个人笔记创建一个日志应用程序,并且在我的Rakefile中包含以下内容:task:newdoentry_name="Entries/#{Time.now.to_s.gsub(/[-\:]+/,'.').gsub(/.0500+/,'')}.md"`touch#{entry_name}``echo"#$(date)">>#{entry_name}`end我想包括的最后一部分是Vim文本编辑器的打开,但我不知道如何打开它,就像我直接从bash终端调用它一样。我试过:vim#{entry_name}但不幸的是,我认为它们都将其作为后台进程打开。我一直在引用“6WaystoRunShe
我要下载http://foobar.com/song.mp3作为song.mp3,而不是让Chrome在其native中打开它浏览器中的播放器。我怎样才能做到这一点? 最佳答案 您只需要确保发送这些header:Content-Disposition:attachment;filename=song.mp3;Content-Type:application/octet-streamContent-Transfer-Encoding:binarysend_file方法为您完成:get'/:file'do|file|file=File.
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:HowdoIgeneratealistofnuniquerandomnumbersinRuby?我想做的事:Random.rand(0..10).timesdoputsRandom.rand(0..10)end但如果随机数已经显示过,则无法再次显示。如何最轻松地做到这一点?
我使用“newapp_name”创建了一个新的Rails应用程序,我正在尝试编辑.gitignore文件,但在我的应用程序文件夹中找不到它。我在哪里可以找到它?我安装了Git。 最佳答案 .gitignore位于项目的root中,而不是app子目录中。首先打开终端并进入您的目录。您需要使用ls-a来显示stash文件。然后使用打开.gitignore 关于ruby-on-rails-尝试打开.gitignore以在文本编辑器中对其进行编辑,但在OSXMountainLion上找不到文件位
我是Ruby的新手,我正在尝试以如下方式打开文件:#!/usr/bin/envrubydata_file='~/path/to/file.txt'file=File.open(data_file,'r')但是我得到“没有这样的文件或目录”(该文件确实存在于该目录中)。如果我将该文件路径作为命令行参数,它会起作用,例如:#!/usr/bin/envrubyfile=File.open(ARGV[0],'r')然后从命令行运行,如:rubyscript.cgi~/path/to/file.txt关于如何让它以第一种方式工作的任何想法? 最佳答案
尝试使用bundleopen命令打开gem源代码,accordingtoofficialdocumentationandinstruction.因此,我在.profile中导出编辑器:exportBUNDLER_EDITOR=viexportEDITOR=vi并尝试打开例如rails使用控制台的源代码:bundleopenrails出现错误CouldnotlocaleGemfile[ruby-2.1.1][~/]$:rails-vRails4.0.3[ruby-2.1.1][~/]$:bundle-vBundlerversion1.5.3[ruby-2.1.1][~/]$:bundle