入门ZXing在Android [英] Getting started with ZXing on Android

查看:216
本文介绍了入门ZXing在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想补充ZXing到我的项目(​​添加一个按钮,它呼吁preSS扫描仪)。我发现这一点:的http://groups.google.com/group/android-developers/browse_thread/thread/788eb52a765c28b5当然还有ZXing首页网站: HTTP://$c$c.google.com/p / zxing / ,但还是没能找出包含在项目类路径,使这一切工作!

I'm trying to add ZXing to my project (add a button which calls the scanner upon press). I found this: http://groups.google.com/group/android-developers/browse_thread/thread/788eb52a765c28b5 and of course the ZXing homesite: http://code.google.com/p/zxing/, but still couldn't figure out what to include in the project classpath to make it all work!

至于现在,我复制了类到我的项目的第一个链接(含部分包名称的变化),并运行,但pssing按钮,并试图安装吧code扫描仪$ P $后崩溃。

As for now, I copied the classes in the first link to my project (with some package name changes), and it runs but crashes after pressing the button and trying to install the barcode scanner.

有些code:

private void setScanButton(){
    Button scan = (Button) findViewById(R.id.MainPageScanButton);
    scan.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            IntentIntegrator.initiateScan(MyActivity.this);
        }
    });
}

产生的误差(来自logcat中):

Resulting error (from logcat):

06-13 15:26:01.540: ERROR/AndroidRuntime(1423): Uncaught handler: thread main exiting due to uncaught exception
06-13 15:26:01.560: ERROR/AndroidRuntime(1423): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://search?q=pname:com.google.zxing.client.android }

想法?

推荐答案

开始<一个href="http://groups.google.com/group/android-developers/browse_thread/thread/788eb52a765c28b5?pli=1">here链接。

在要触发酒吧code扫描活动包括:

In the activity that you want to trigger a barcode scan include

IntentIntegrator.initiateScan(YourActivity.this); 

,然后还包括:

and then also include:

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            // Handle successful scan
            TextView 
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
};

酒吧code扫描仪的应用程序来处理实际的扫描。如果 酒吧$未安装的C $ C扫描仪应用程序,积分会促使他们 进行安装。

The Barcode Scanner app will handle the actual scanning. If the Barcode Scanner app is not installed, the integrator will prompt them to install it.

-----------从nEx.Software ---------------

----------- From nEx.Software ---------------

这篇关于入门ZXing在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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