Thursday 15 January 2015

cordova - Phonegap barcodescanner encode function stops app -



cordova - Phonegap barcodescanner encode function stops app -

i using barcodescanner.js plugin in phonegap app , working great next 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); });

but having issue when encode finishes app stops. have got illustration code of creating additional function invoke success callback. requirement display barcode/qr code in screen saved phone text data.

i used whole day searching this. found on here: https://github.com/wildabeast/barcodescanner/issues/71

you need search menu/encode.xml in file explorer project's root , replace with: http://zxing.googlecode.com/svn/trunk/android/res/menu/encode.xml

if link ever unavailable, here code:

<?xml version="1.0" encoding="utf-8"?> <!-- copyright (c) 2012 zxing authors licensed under apache license, version 2.0 (the "license"); may not utilize file except in compliance license. may obtain re-create of license @ http://www.apache.org/licenses/license-2.0 unless required applicable law or agreed in writing, software distributed under license distributed on "as is" basis, without warranties or conditions of kind, either express or implied. see license specific language governing permissions , limitations under 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 needs improve community page , documentation.

cordova phonegap-plugins barcode-scanner

No comments:

Post a Comment