BlackBerry WebWorks应用例子:扫描条码barcode
来源:互联网 发布:网络传销报警有用吗 编辑:程序博客网 时间:2024/04/24 08:59
条码扫描 API,例子代码
1)Locate your BlackBerry WebWorks SDK for Smartphone extensions directory using your File Explorer. Default path is
C:\Program Files\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext
2)Create a new webworks.media.barcode directory in the ext directory
3)Download the source from this repository and unzip it to a location on your computer
4)Using File Explorer browse to this extension's downloaded source code Smartphone\Barcode
5)Copy the library.xml file from the downloaded Smartphone\Barcode directory to your new ext\webworks.media.barcode directory
6)Copy webworks directory from the downloaded Smartphone\Barcode\ directory to your new ext\webworks.media.barcode\blackberry directory
Required Feature ID
Whenever you use the below feature id in any of your WebWorks applications this extension will be loaded for use.
<feature id="webworks.media.barcode" />
错误处理1:
https://github.com/blackberry/WebWorks-Community-APIs/issues/67
Ripple或者bbwp命令行编译错误:
[Fatal Error] library.xml:16 : 6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
[ERROR] Feature cannot be found in any extension(webworks.media.barcode)
解决办法:
去掉 library.xml前面15行的注释
===================================================================================================
错误处理2:
终止扫描,成功扫描后,再次进行扫描,会报错,提示关闭Player。
解决办法:
在两处_scanner.stopScan();后面加入 _scanner.getPlayer().close();
在两处 UiApplication.getUiApplication().popScreen(ScannerScreen.this); 前面加入 closePlayer();
public void closePlayer() {
try
{
_scanner.stopScan();
_scanner.getPlayer().close();
}
catch (MediaException me)
{
returnError("Error: " + me.getMessage());
}
===================================================================================================
https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Smartphone/Barcode
===================================================================================================
配置方法:
How To Configure The Extension For Use1)Locate your BlackBerry WebWorks SDK for Smartphone extensions directory using your File Explorer. Default path is
C:\Program Files\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext
2)Create a new webworks.media.barcode directory in the ext directory
3)Download the source from this repository and unzip it to a location on your computer
4)Using File Explorer browse to this extension's downloaded source code Smartphone\Barcode
5)Copy the library.xml file from the downloaded Smartphone\Barcode directory to your new ext\webworks.media.barcode directory
6)Copy webworks directory from the downloaded Smartphone\Barcode\ directory to your new ext\webworks.media.barcode\blackberry directory
Required Feature ID
Whenever you use the below feature id in any of your WebWorks applications this extension will be loaded for use.
<feature id="webworks.media.barcode" />
错误处理1:
https://github.com/blackberry/WebWorks-Community-APIs/issues/67
Ripple或者bbwp命令行编译错误:
[Fatal Error] library.xml:16 : 6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
[ERROR] Feature cannot be found in any extension(webworks.media.barcode)
解决办法:
去掉 library.xml前面15行的注释
===================================================================================================
错误处理2:
终止扫描,成功扫描后,再次进行扫描,会报错,提示关闭Player。
解决办法:
在两处_scanner.stopScan();后面加入 _scanner.getPlayer().close();
在两处 UiApplication.getUiApplication().popScreen(ScannerScreen.this); 前面加入 closePlayer();
public void closePlayer() {
try
{
_scanner.stopScan();
_scanner.getPlayer().close();
}
catch (MediaException me)
{
returnError("Error: " + me.getMessage());
}
}
/** Copyright 2011 Research In Motion Limited.** 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.*/package webworks.media.barcode.UI;import java.util.Hashtable;import javax.microedition.media.MediaException;import webworks.media.barcode.ErrorObject;import net.rim.device.api.barcodelib.BarcodeDecoder;import net.rim.device.api.barcodelib.BarcodeDecoderListener;import net.rim.device.api.barcodelib.BarcodeScanner;import net.rim.device.api.script.ScriptableFunction;import net.rim.device.api.system.Characters;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.container.MainScreen;public class ScannerScreen extends MainScreen {private BarcodeScanner _scanner;private ScriptableFunction _captureCallback;private ScriptableFunction _errorCallback; /** * Creates a new ViewFinderScreen object */ public ScannerScreen(final ScriptableFunction captureCallback,final ScriptableFunction errorCallback, final Hashtable hints ) { _captureCallback = captureCallback; _errorCallback = errorCallback; // Initialize the BarcodeDecoder BarcodeDecoder decoder = new BarcodeDecoder(hints); // Create a custom instance of a BarcodeDecoderListener to pop the // screen and display results when a barcode is recognized. BarcodeDecoderListener decoderListener = new BarcodeDecoderListener() { /** * @see BarcodeDecoderListener#barcodeDecoded(String) */ public void barcodeDecoded(String rawText) { returnSuccess(rawText); } }; try { // Initialize the BarcodeScanner object and add the associated // view finder. _scanner = new BarcodeScanner(decoder, decoderListener); _scanner.getVideoControl().setDisplayFullScreen(true); add(_scanner.getViewfinder()); } catch(Exception e) { returnError("Error: " + e.getMessage()); } } /** * Informs the BarcodeScanner that it should begin scanning for QR Codes */ public void startScan() { try { _scanner.startScan(); } catch(MediaException me) { returnError("Error: " + me.getMessage()); } } /** * @see net.rim.device.api.ui.Screen#keyChar() */ protected boolean keyChar(char key, int status, int time) { if (key == Characters.ESCAPE) { // Manually stop the scanning process and pop the screen try { _scanner.stopScan();_scanner.getPlayer().close();//Jiang Yang UiApplication.getUiApplication().popScreen(ScannerScreen.this); } catch (MediaException me) { returnError("Error: " + me.getMessage()); } } return super.keyChar(key, status, time); } /** * @see net.rim.device.api.ui.Screen#close() */ public void close() { try { _scanner.stopScan();_scanner.getPlayer().close();//Jiang Yang UiApplication.getUiApplication().popScreen(ScannerScreen.this); } catch (MediaException me) { returnError("Error: " + me.getMessage()); } super.close(); } //Jiang Yangpublic void closePlayer() { try { _scanner.stopScan();_scanner.getPlayer().close(); } catch (MediaException me) { returnError("Error: " + me.getMessage()); }} /** * Pops the ViewFinderScreen and displays text on the main screen * * @param text Text to display on the screen */ private void returnSuccess(final String text) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { closePlayer(); //Jiang Yang UiApplication.getUiApplication().popScreen(ScannerScreen.this); try {_captureCallback.invoke(null, new Object[] { text });} catch (Exception e) {} } }); } /** * Pops the ViewFinderScreen and displays text on the main screen * * @param text Text to display on the screen */ public void returnError(final String text) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { closePlayer(); //Jiang YangUiApplication.getUiApplication().popScreen(ScannerScreen.this); try {_errorCallback.invoke(null,new Object[] {new ErrorObject(-1, text)});} catch (Exception e) {} } }); }}
===================================================================================================
- BlackBerry WebWorks应用例子:扫描条码barcode
- BlackBerry 10 BIS推送数据到应用(WebWorks例子应用)
- BlackBerry 9850 应用:条码 二维码扫描
- HTML5+规范:barcode(条码扫描)
- HTML5+规范:barcode(条码扫描)
- BlackBerry WebWorks例子程序Weather在Ripple中编译错误
- BlackBerry WebWorks 手机应用提示用户的几种方式
- 制作条码(barcode)
- C# Barcode 条码
- 跨平台移动开发phonegap/cordova 3.3全系列教程-条码扫描barcode
- 条码扫描
- 条码BarCode打印识别问题
- halcon学习6,可视化条码扫描的例子学习
- BlackBerry WebWorks SDK for Tablet OS主网站
- Using Invoke APIs in your BlackBerry WebWorks app
- Blackberry WebWorks Forum's Tips, Quirks & Solutions Thread
- Building Your First HTML5 App Using BlackBerry WebWorks APIs
- BlackBerry WebWorks API监控手机上进来的邮件
- 何为中国特色
- Linux线程初探
- Microsoft SQL Server 2008 R2 Express Service Pack1官方下载地址
- 2012读书清单
- cocos2d 骨骼动画相关资源
- BlackBerry WebWorks应用例子:扫描条码barcode
- 如何迅速成为Java高手
- SWT无标题栏窗口的拖动
- 2012.7.14计划
- 如何解决delphi2007中UTF-8转码的奇数汉字出错的问题
- 2012-7-14 周六 计划
- 我的一些个人链接
- 2012.7.14计划
- 四大名捕---java集合类框架概述