I'm developing a ZXing project in Eclipse:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view)
{
Log.d("test", "button works!");
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
b1 = (Button)findViewById(R.id.button111);
}
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");
Log.i("xZing", "contents: "+contents+" format: "+format);
// Handle successful scan
}
else if (resultCode == RESULT_CANCELED)
{
// Handle cancel
Log.i("xZing", "Cancelled");
}
}
I found the finder pattern coordinates are in the Detector
class (getTopLeft
and getTopRight
and getBottomLeft
) but when I want to access them I'm facee with errors in the code. I don't know how I can access these variables. For example, I define a public static FinderPattern topLeft1
in the Detector
class and in the processFinderPatternInfo
method I add topLeft1=topLeft
.
After startActivity
for the result I add:
float m1=Detector.topLeft1.x;
m2=Detector.topLeft1.y;
b.setText("(x,y)="+m1+","+m2);
but when I run the program and click the button to scan: I get:
unfortunately zxing has stopped
I need 10 reputation to post an image and I can't post logcat image :-( Can any one help me soon? Thanks a lot
I solved my problem.I must write OnActivityResult class out of OnCreate Method! That's all! thank you all.