Zxing如何使扫描结果传播回调用活动

时间:2013-01-13 12:10:27

标签: android zxing

我已将ZXing代码集成到我的应用中。我被告知不要将整个图像复制并粘贴到我的应用程序中,而是采取我需要的部分。我从捕获活动开始,然后将其依赖项复制到我的应用程序中。我将意图过滤器从zxing改为了我的意图过滤器。哦,我必须在capture.xml中更改包名称。

似乎工作正常,当我的活动调用startActivityForResult()扫描程序启动时。问题是当我扫描QRcode时,扫描结果不会传播回我的调用活动,而是询问如何完成动作,例如短信,电子邮件等。

如何让扫描结果回到我的活动onActivityResult?

先谢谢了

 Button signin = (Button)findViewById(R.id.buttonsignin);

        alpha = new AlphaAnimation(0.3F, 0.8F); //Set opacity - Range 0.0 to 1.0
        alpha.setDuration(0); // Set animation duration
        alpha.setFillAfter(true); // Maintaining the effect to the button
        signin.startAnimation(alpha);
        signin.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Log.e(TAG, "onclicked sign in");

                Intent intent = new Intent(
                        "com.carefreegroup.SCAN");
                intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

                startActivityForResult(intent, 0);

            }
        });

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        Log.e(TAG, "in onActivityResult");
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                Log.e(TAG, "result ok");

//              
                ///////////////////////////////



                tagScanTime  = new DateTime();

                DateTimeFormatter df = DateTimeFormat.forPattern("dd/MMM/yy h:mmaa");
                String formattedScanTime = df.print(tagScanTime);
                Log.e(TAG, "formatted tag scan time = " + formattedScanTime);



                 contents = intent.getStringExtra("SCAN_RESULT");
//              Toast.makeText(this, "scanner has found " + contents,
//                      Toast.LENGTH_LONG).show();

                 //get info from tag that has been just scanned
                    String[] splitPayload = contents.split(",");

                    tagType = splitPayload[0];
                    tagCompany = splitPayload[1];
                    tagCompany = nfcscannerapplication.getCompId();
                    //tagPerson = splitPayload[2];
                    cursor = nfcscannerapplication.loginValidate.queryAllFromCarer();
...............
..............
..............

<activity android:name=".CaptureActivity" >
            <intent-filter>
                <action android:name="com.carefreegroup.SCAN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

0 个答案:

没有答案