我正在 Eclipse 中开发一个 ZXing 项目:
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");
}
}
我发现查找器模式坐标在Detector
类(getTopLeft
和getTopRight
和getBottomLeft
)中,但是当我想访问它们时,我遇到了代码错误。我不知道如何访问这些变量。例如,我public static FinderPattern topLeft1
在Detector
类和processFinderPatternInfo
我添加的方法中定义了 a topLeft1=topLeft
。结果后startActivity
我添加:
float m1=Detector.topLeft1.x;
m2=Detector.topLeft1.y;
b.setText("(x,y)="+m1+","+m2);
但是当我运行程序并单击按钮进行扫描时:我得到:
不幸的是zxing已经停止
我需要 10 个声望才能发布图片,但我无法发布 logcat 图片 :-( 有人能尽快帮助我吗?非常感谢