Guest glossywhite Posted April 23, 2011 Report Share Posted April 23, 2011 (edited) Hi. I'm accessing "ZXing" barcode scanner via intents with the SDK & Eclipse. This code works, right up to when I expect the TextView to be updated with the scanned data in a String... and then it crashes. Any ideas where I've messed up? package com.matt.barcode; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class ScanQR extends Activity implements OnClickListener { public Button scanCode; public TextView showScan; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); scanCode = (Button)findViewById(R.id.scanCode); scanCode.setOnClickListener(this); } @Override public void onClick(View v) { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.setPackage("com.google.zxing.client.android"); intent.putExtra("SCAN_MODE","PRODUCT_MODE"); startActivityForResult(intent, 0); } public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { String contents = intent.getStringExtra("SCAN_RESULT"); showScan.setText(contents); String format = intent.getStringExtra("SCAN_RESULT_FORMAT"); // Handle successful scan } else if (resultCode == RESULT_CANCELED) { showScan.setText("Please try again"); // Handle cancel } } } } Muchly thankful :) Edited April 23, 2011 by glossywhite Link to comment Share on other sites More sharing options...
Guest glossywhite Posted April 24, 2011 Report Share Posted April 24, 2011 Sorry, I think I must have posted in the wrong place. I was told this was an Android forum... Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now