不显示显示结果qr scan(zxing,android)

时间:2015-05-18 19:20:36

标签: java android zxing

我正在使用zixing libruary,当我扫描qr代码时,它的显示结果低于相机开启时,几秒钟。

用户扫描qr时如何显示结果?用户必须不知道显示结果。

MainActivity:

public class MainActivity extends Activity {

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent intent = new Intent(ACTION_SCAN);
        //intent.setPackage("com.example.bonsitemanager");
        intent.putExtra("SCAN_MODE", "QR_CODE_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");
              String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

              Log.e(contents, contents);
              Log.e(format, format);

           } else if (resultCode == RESULT_CANCELED) {
              // Handle cancel
              Log.i("App","Scan unsuccessful");
           }
      }
   }

0 个答案:

没有答案