问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

有没有人用过phonegap做条形码的扫描

发布网友 发布时间:2022-04-20 02:04

我来回答

1个回答

热心网友 时间:2022-04-20 03:33

Phonegap条形码扫描插件说明文档
Originally by Matt KaneUpdates by Simon MacDonald

Adding the Plugin to your project

1. Add the 'LibraryProject' into Eclipse. File -> New Android Project -> create project from existing source.
2. In the new project you've just added to Eclipse go to the project properties. Select the Android section and at the bottom of the dialog check the "Is Library" checkbox.
3. In your application go into the project properties. In the Android section under library click the Add button and select the library you created in step 2.
4. To install the plugin, move barcodescanner.js to your project's www folder and include a reference to it in your html files.
5. Create a folder called 'com/phonegap/plugins/barcodescanner' within your project's src folder.
6. And copy the BarcodeScanner.java file into that new folder.

`mkdir <your_project>/src/com/phonegap/plugins/barcodescanner`

`cp ./src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java <your_project>/src/com/phonegap/plugins/barcodescanner`

7. In your res/xml/plugins.xml file add the following line:

`<plugin name="BarcodeScanner" value="com.phonegap.plugins.barcodescanner.BarcodeScanner"/>`

8. Add the following activity to your AndroidManifest.xml file. It should be added inside the <application/> tag.

`<!-- ZXing activities -->
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>`

使用插件
The plugin creates the object `window.plugins.barcodeScanner` with the method `scan(success, fail)`.
The following barcode types are currently supported:

QR_CODE
DATA_MATRIX
UPC_E
UPC_A
EAN_8
EAN_13
CODE_128
CODE_39
CODE_93
CODABAR
ITF
RSS14
PDF417
RSS_EXPANDED

success and fail are callback functions. Success is passed an object with data, type and cancelled properties. Data is the text representation of the barcode data, type is the type of barcode detected and cancelled is whether or not the user cancelled the scan.

完整的实例:

window.plugins.barcodeScanner.scan( function(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}, function(error) {
alert("Scanning failed: " + error);
}
);

创建条形码
The plugin creates the object window.plugins.barcodeScanner with the methodencode(type, data, success, fail).
Supported encoding types:

TEXT_TYPE
EMAIL_TYPE
PHONE_TYPE
SMS_TYPE

完整的示例:

window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
alert("encode success: " + success);
}, function(fail) {
alert("encoding failed: " + fail);
}
);

Licence

The MIT License

Copyright (c) 2010 Matt Kane

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
新手小白做跨境电商,半年赚了5万+,现在入场还不晚! 个人做跨境电商赚钱吗?需要投资多少钱? 玫瑰·屠格涅夫散文诗集图书目录 屠格涅夫散文精选图书目录 工行手机银行怎么办理etc 办理etc的方法 年轻人得眩晕症的后果 年轻人耳石症是怎么造成的(耳石症是怎么造成的) 蛋仔派对 蛋仔派对小苹果套装怎么获得? 雪雪怎么赠送 蛋仔派对 蛋仔派对白雪公主皮肤怎么获得? 可以申请法院调查取证吗 申请法院调查取证几个当事人可不可以共写一份申请书 招财猫坏了摆放是好还是不好 2022年属虎和属猴的一家人店里放什么招财? 五行属什么不能摆招财猫?我是属木的,行业也是木业 属猴的人养猫会破财吗 家里有属猴的孩子不能摆放招财猫吗 属猴的摆放招财猫好不好 属猴人不用的招财猫能不能放在家里 我们饭店刚开张招财猫不对着门口放可以吗? 还有看到百度说属猴的不能放招财猫是真的吗? 属猴的能放招财猫吗?适合放什么在店里呢 qq加人要验证是我的号危险了吗 给狗狗取什么名字能代表财源广进,大吉大利 广汉三星堆的作者简介 【开心学国学】四川广汉的三星堆遗址,其形成及命名与我国古代的三星崇拜有关系吗? 三星堆的名字怎么来的啊? 派出所销户需要什么证明 注销户口的理由怎么写 取消户口申请书怎么写 苹果最新mac pro什么时候在中国发售 水库保洁项目做什么 :五星电器我在五星买了一台空调,第二天,五星的安装人员说:无法安装,需要80元的安装费才能安装。。。。 有谁了解五星电器退换货规定? 五星电器在合肥有几家售后服务地址 京东五星电器集团有限公司盐城解放中路分公司怎么样? 江苏五星电器有限公司盐城大卖场怎么样? 盐城的苏宁国美五星电器在哪 去盐城五星电器国庆短期打工面试,结果她叫我们回家等通知。过了几天之后,打电话询问,那女的非但不解释 江苏五星电器有限公司大丰大卖场怎么样? 江苏五星电器有限公司射阳解放路店怎么样? 谁知道盐城市里哪里有适合女生学跳舞的地方啊? 福建2级工伤伤残赔偿标准与计算方法 这里有道排列组合题,用位置分析法得出的答案和用元素分析法得出的答案不一样,哪个错了,为什么? 关于排列 组合的问题 六人按要求站成一排,甲不站在两端 有多少种不同的站法 ? 排队,两个人站成一排有几种站法 从6名短跑运动员中选出4人参加4*100m接力赛,甲不能跑第一棒和第四棒,共有几种方案? 四名男生和三名女生站成一排,一共有多少种站法 高三排列组合问题 用0.1.2组数,要求相邻两个数字不相同,一共可以组成几个不同的三位数?