Re: Data Matrix scanning issues

163 views
Skip to first unread message

Sean Owen

unread,
Jul 19, 2012, 9:15:39 AM7/19/12
to zx...@googlegroups.com
This scans instantly in Barcode Scanner. Are you sure you are using Intents if not using IntentIntegrator? I am not sure you're really using Barcode Scanner, in which case I'd suggest it's an issue with your app. Otherwise, make sure you have actually asked to scan Data Matrix.

STCK

unread,
Jul 19, 2012, 9:38:10 PM7/19/12
to zx...@googlegroups.com
As i said in the first post, sometimes it is scanned in a few seconds or it can take minutes, and not scan at all. Sometimes i have to "zoom" in out by physically moving my camera closer to or further from the image

Here is my code....
.
 public class ScanActivity extends Activity {
String contents,format,filename,mode;
private Button bcButton;
    
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.scan);      
       
        this.bcButton = (Button)this.findViewById(R.id.scanBCButton);
        this.bcButton.getBackground().setColorFilter(Color.RED,PorterDuff.Mode.MULTIPLY); 
        
   //     this.QRButton = (Button)this.findViewById(R.id.scanQRButton);
    //    this.QRButton.getBackground().setColorFilter(Color.RED,PorterDuff.Mode.MULTIPLY); 
        
        Bundle extras = getIntent().getExtras(); 
        if (extras != null) { 
             filename = extras.getString("FILE_NAME"); 
             mode = extras.getString("MODE"); 
        }

    }
    
    public void ScanbuttonClickHandler(View view) {
    Intent intent = new Intent("com.google.zxing.client.android.SCAN"); 
         intent.setPackage("com.google.zxing.client.android"); 
         //intent.putExtra("SCAN_MODE","SCAN_MODE" ); 
         startActivityForResult(intent, 0); 
    }
    
    /*
    public void ScanQRbuttonClickHandler(View view) {
    Intent intent = new Intent("com.google.zxing.client.android.SCAN"); 
        intent.setPackage("com.google.zxing.client.android"); 
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); 
        startActivityForResult(intent, 0); 
   }
   */
    
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                contents = intent.getStringExtra("SCAN_RESULT");
                format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                              
                Intent intent2 = new Intent(getApplicationContext(), DisplayActivity.class); 
                intent2.putExtra("CONTENTS", contents); 
                intent2.putExtra("FILENAME", filename);
                intent2.putExtra("MODE", mode);
                
                if(mode.equals("update")){
                startActivityForResult(intent2,8);
                }else{
                startActivity(intent2);
                }
                
            } else if (resultCode == RESULT_CANCELED) {
                // Handle cancel
Toast toast = Toast.makeText(this, "Scan was Cancelled!",
Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP, 25, 500);
toast.show();
            }
        }
        
        if(requestCode==8){
        finish();
       
        }
           
    }
 
}




On Thursday, July 19, 2012 10:17:59 PM UTC+9:30, STCK wrote:
I am using an intent to "integrate" zxing into my android app (not IntentIntegrator)

I used the referenced website to create the attached code.

When i attempt to scan the code, i have varying success rates. sometimes it scans within seconds other times it takes minutes, or doesnt scan at all. i have to make the code larger or smaller in my viewfinder rectangle to get a scan

any ideas???

STCK

unread,
Jul 19, 2012, 9:39:05 PM7/19/12
to zx...@googlegroups.com
Initially i was only scanning product codes using

   intent.putExtra("SCAN_MODE","PRODUCT_MODE" );  

which i then changed to 

   intent.putExtra("SCAN_MODE","SCAN_MODE" ); 

which i have now commented out

   //intent.putExtra("SCAN_MODE","SCAN_MODE" );  

STCK

unread,
Jul 19, 2012, 10:07:03 PM7/19/12
to zx...@googlegroups.com
This wont scan either
WontScan.png

Sean Owen

unread,
Jul 20, 2012, 3:19:10 AM7/20/12
to zx...@googlegroups.com
QR_CODE_MODE would restrict to QR codes and not scan for Data Matrix."SCAN_MODE" is not valid. Try setting "SCAN_FORMATS" to "DATA_MATRIX".
I'm not sure what the other barcode format is, maybe Code 128. It also won't scan if you select a mode that excludes that format. Or it may just be that it's too small / you're holding too close to scan effectively.

STCK

unread,
Jul 20, 2012, 3:24:07 AM7/20/12
to zx...@googlegroups.com
i get the same behaviour from my app as the Barcode Scanner app, its a bit of pot luck how long it takes to get a scan locked.

i will try with SCAN_FORMATS 

i thought if i dont pass the intent and SCAN_MODE, then it will scan for ALL formats the code supports ????

STCK

unread,
Jul 20, 2012, 3:44:52 AM7/20/12
to zx...@googlegroups.com
from many examples on the net i see 

  intent.putExtra("SCAN_MODE","PRODUCT_MODE" );   

i thought "SCAN_MODE" requests all codes support???

Does 

 intent.putExtra("SCAN_MODE","PRODUCT_MODE" );   

only scan "PRODUCT_MODE", and thus could be replaced with

  intent.putExtra("PRODUCT_MODE" );   



On Friday, July 20, 2012 4:49:10 PM UTC+9:30, Sean Owen wrote:

Sean Owen

unread,
Jul 20, 2012, 4:17:47 AM7/20/12
to zx...@googlegroups.com
The app defaults to scanning for whatever the user has selected in the app. It may or may not include 2D codes.

"PRODUCT_MODE" certainly doesn't mean all formats. It means 1D formats used to label products, like UPC. It would exclude DM.

You can't use "PRODUCT_MODE" as a key, don't know what you mean.

Like I said, as you can see Barcode Scanner scans it instantly. I think you are sending the wrong intents.

STCK

unread,
Jul 20, 2012, 5:24:52 AM7/20/12
to zx...@googlegroups.com
See my code to see I am not setting any mode. It was originally (SCAN_MODE, PRODUCT_MODE) , but I have now commented it out. I get the same behaviour as Barcode Scanner. Even with Barcode Scanner Data matrix takes some effort to get a scan.
Reply all
Reply to author
Forward
0 new messages