Skip to content Skip to sidebar Skip to footer

Integrate Zxing Without The Use Of A 3rd Party Scanner?

I've read numerous topics already where people asked how to integrate ZXing in an Android application where they necessarily need to have a 3rd party scanner app installed in order

Solution 1:

This is confused, and the approach you have accepted is harmful.

First, please do not copy our app wholesale, as we have repeatedly stressed here. It is not only discouraged, but violates our trademark if you clone the UI. Just don't do it.

Second, you are copying our code, but then are trying to use a scanner by Intent. Why? If you want to use Intents, you don't need to use any code.

Third, you are declaring your app to respond to our app Intent. You are intercepting calls intended for Barcode Scanner. If you can reply in exactly the same way, OK, but, I imagine you are not guaranteeing this. By doing so you're harming users of Barcode Scanner, the open source project you're profiting from.

Solution 2:

Modify your Manifest and add this

<activityandroid:configChanges="orientation|keyboardHidden"android:name="com.google.zxing.client.android.CaptureActivity"android:screenOrientation="landscape"android:theme="@android:style/Theme.NoTitleBar.Fullscreen"android:windowSoftInputMode="stateAlwaysHidden" ><intent-filter ><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter><intent-filter ><actionandroid:name="com.google.zxing.client.android.SCAN" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>

also add camera permission

<uses-permissionandroid:name="android.permission.CAMERA"/>

and implemetn onActivityResult method in your Activity

publicvoidonActivityResult(int requestCode, int resultCode, Intent intent) 
    {
        if (requestCode == 0) 
        {
            if (resultCode == RESULT_OK)
            {
                Stringcontents= intent.getStringExtra("SCAN_RESULT");
                Stringformat= intent.getStringExtra("SCAN_RESULT_FORMAT");
                Log.i("xZing", "contents: "+contents+" format: "+format);
                // Handle successful scan
            } 
            elseif (resultCode == RESULT_CANCELED)
            {
                // Handle cancel
            }
        }
    }

for more information or any trouble see this link

Post a Comment for "Integrate Zxing Without The Use Of A 3rd Party Scanner?"