Getting started with ZXing on Android

I am trying to add ZXing to my project (add a button that invokes the scanner when clicked). I found this: http://groups.google.com/group/android-developers/browse_thread/thread/788eb52a765c28b5 and of course ZXing homesite: http://code.google.com/p/zxing/ , but that's it I still could not understand what to include in the path to the project class so that all this worked.

At the moment, I copied the classes in the first link to my project (with some changes to the package name), and it starts, but it crashes after clicking a button and trying to install a barcode scanner.

Some codes:

private void setScanButton(){
    Button scan = (Button) findViewById(R.id.MainPageScanButton);
    scan.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            IntentIntegrator.initiateScan(MyActivity.this);
        }
    });
}

Resulting error (from logcat):

06-13 15:26:01.540: ERROR/AndroidRuntime(1423): Uncaught handler: thread main exiting due to uncaught exception
06-13 15:26:01.560: ERROR/AndroidRuntime(1423): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://search?q=pname:com.google.zxing.client.android }

Ideas?

+3
8

.

, -,

IntentIntegrator.initiateScan(YourActivity.this); 

:

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");
            // Handle successful scan
            TextView 
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
};

- . " -" , .

----------- nEx.Software ---------------

+7

-, ZXing , Market. APK Barcode Scanner .

-, , -, , . , .

+3

application:

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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.zxing.client.android.SCAN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

, , :

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

+1

AndroidManifest, android: name " . " ActivityNotFoundException", , ZXing com.google.zxing.client.android. ZXing, . .

0

- , . , :

0

zxing, * 1 *, zxing, , , . QR- Android . bigenner.good luck. , ;

0
  • SD- .
  • BarcodeScaner ZXing
  • .
  • adb shell input text 'https://code.google.com/p/zxing/downloads/detail?name=BarcodeScanner-4.5.1.apk&can=2&q=' - ZXing
  • , . .
0

Zxing () ( Material Design), :

IntentIntegrator = IntentIntegrator (getActivity()); integrator.forSupportFragment().initiateScan();

onActivityResult()

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == IntentIntegrator.REQUEST_CODE) {

            String contents = data.getStringExtra("SCAN_RESULT");
            String format = data.getStringExtra("SCAN_RESULT_FORMAT");
            Log.i(TAG, "Barcode Result: " + contents);
            etc...
        }
    }

Manifest.xml

    <activity
        android:name="com.google.zxing.client.android.CaptureActivity"
        android:configChanges="orientation|keyboardHidden"
        android:windowSoftInputMode="stateAlwaysHidden" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.zxing.client.android.SCAN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

. intents startActivityForResult(). QR-, .

build.grade :

repositories {mavenCentral () maven {url " https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/ "}}

compile 'com.google.zxing:core:3.2.1'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
0
source

Source: https://habr.com/ru/post/1749828/


All Articles