Android Xzing library (read barcode) with fragment

3

My application worked perfectly with Zxing, after implementing fragment, the barcode reading stopped working. I tried configuring the return in the fragment, in the activity ... but I was not successful. Has anyone been able to do this implementation?

    
asked by anonymous 09.07.2015 / 04:44

1 answer

2

Call:

    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.putExtra("SCAN_MODE", "ONE_D_MODE");
    startActivityForResult(intent, 0);

Reception:

    public void onActivityResult(int requestCode, int resultCode, Intent intent){
    if (requestCode == 0){
        if (resultCode ==  Activity.RESULT_OK) {

            String contents = intent.getStringExtra("SCAN_RESULT");


        }
        else if (resultCode == Activity.RESULT_CANCELED){
            Toast.makeText(getActivity(), "Scan unsuccessful", Toast.LENGTH_SHORT).show();

        }
    }
}

Here it works perfectly!

    
09.07.2015 / 16:58