Phonegap条码扫描器编码功能停止应用程序 [英] Phonegap barcodescanner encode function stops app

查看:94
本文介绍了Phonegap条码扫描器编码功能停止应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的phonegap应用程序中使用条形码扫描器.js插件,对于下面的代码,一切工作正常.

I am using barcodescanner.js plugin in my phonegap app and everything is working great for the following code.

var scanner = cordova.require("cordova/plugin/BarcodeScanner");
  scanner.encode(scanner.Encode.TEXT_TYPE, 123456789, function(success) {
             alert("encode success: " + success);
           }, function(fail) {
             alert("encoding failed: " + fail);
           });

,但是在编码完成时出现问题,应用停止了.有没有人得到创建附加函数来调用成功回调的任何示例代码. 我的要求是从保存的电话文本数据中在屏幕上显示条形码/QR码.

but having an issue when encode finishes app stops. Have anyone got any example code of creating an additional function to invoke the success callback. My requirement is to display barcode/QR code in the screen from saved phone text data.

推荐答案

我整天都在寻找这个.在这里找到它: https://github.com/wildabeast/BarcodeScanner/issues/71

I used my whole day searching for this. Found it on here: https://github.com/wildabeast/BarcodeScanner/issues/71

您需要从项目的根目录中在文件资源管理器中搜索menu/encode.xml,并将其替换为:

You need to search for menu/encode.xml in your file explorer from your project's root and replace it with: http://zxing.googlecode.com/svn/trunk/android/res/menu/encode.xml

如果该链接永远不可用,则代码如下:

If the link is ever unavailable, here is the code:

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (C) 2012 ZXing authors

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/menu_share"
        android:title="@string/menu_share"
        android:icon="@android:drawable/ic_menu_share"
        android:orderInCategory="1"
        android:showAsAction="withText|ifRoom"/>
  <item android:id="@+id/menu_encode"
        android:title="@string/menu_encode_vcard"
        android:icon="@android:drawable/ic_menu_sort_alphabetically"
        android:orderInCategory="2"
        android:showAsAction="withText|ifRoom"/>
</menu>

Phonegap确实需要更好的社区页面和文档.

Phonegap really needs a better community page and documentation.

这篇关于Phonegap条码扫描器编码功能停止应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆