我正在开发一个条码扫描应用程序并使用 Zxing 作为条码扫描器。我的应用程序向 Zxing 发送了一个意图,该意图启动并允许我扫描条形码,但是......我无法取回任何数据。我没有将条形码编号返回到我的应用程序,因此我可以在我的代码中使用它们。
以下是我的代码:
public class ScaningActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent scanIntent = new Intent("com.google.zxing.client.android.SCAN");
scanIntent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(scanIntent, 0);
}//close onCreate
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
// handle scan result
Log.e("DATA", "TESTING SCAN RESULT : " + scanResult.toString());
}else{
Log.d("DATA", "NO SCAN RESULTS : ");// + scanResult.getFormatName());//scanResult.getContents());
}
// else continue with any other code you need in the method
Log.i("DATA", "Continuing after scan result");
Log.d("DATA", "requestCode : " + requestCode);
Log.d("DATA", "resultCode : " + resultCode);
Log.d("DATA", "intent : " + intent);
}
}//close ScaningActivity
在onActivityResult
函数中,我收到NO SCAN RESULTS消息。
我究竟做错了什么?