попробуйте код ниже.Это рабочий код, который я использовал сам.
public class MyTestActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Button b = new Button(this);
b.setText("Scan");
b.setWidth(100);
LinearLayout ll = new LinearLayout(this);
b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
}
});
ll.addView(b);
setContentView(ll);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// IntentResult scanResult = IntentIntegrator.parseActivityResult(
// requestCode, resultCode, intent);
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
Dialog d = new Dialog(this);
LinearLayout ll = new LinearLayout(this);
TextView tv = new TextView(this);
tv.setText(contents+" "+format);
ll.addView(tv);
d.setContentView(ll);
d.show();
}
}
}
}
надеюсь, это поможет