java - scan qrcode closing app instead of providing result -



java - scan qrcode closing app instead of providing result -

i'm using zxing library provide qrcodes , scanning application i'm stuck on issue. when attempting scan, i've tried several methods. recommended:

intentintegrator integrator = new intentintegrator(this); integrator.initiatescan();

or intent method:

intent intent = new intent("com.google.zxing.client.android.scan"); intent.putextra("scan_mode", "qr_code_mode"); this.startactivityforresult(intent, 0);

both appear work fine scan app or take app handle intent dialog appears. however, after scanning, app closes. no errors , no results. bye-bye.

method grab result, note log.d after super() never displayed.

@override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); log.d(log_tag, "resultcode = " + resultcode); switch (requestcode) { case intentintegrator.request_code: intentresult scanresult = intentintegrator.parseactivityresult( requestcode, resultcode, data); if (scanresult == null) { return; } final string result = scanresult.getcontents(); // result if (result != null) { log.d(log_tag, "your result is: " + result); } break; default: } }

i've seen references in tutorials explaining how implement zxing create entries in androidmanifest.xml. seen below:

<activity android:name="com.google.zxing.client.android.captureactivity" android:screenorientation="landscape" android:configchanges="orientation|keyboardhidden" 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.default"/> </intent-filter> <intent-filter> <action android:name="com.google.zxing.client.android.scan"/> <category android:name="android.intent.category.default"/> </intent-filter> </activity>

i'm not having luck far , lack of logs isn't helping point me in direction.

i'm using android studio , have gradle setup libs in dependencies:

compile files('libs/core-3.1.1.jar') compile files('libs/android-integration-3.1.1.jar')

help appreciated.

try this

public void onactivityresult(int requestcode, int resultcode, intent intent) { intentresult scanresult = intentintegrator.parseactivityresult(requestcode, resultcode, intent); if (scanresult != null) { // handle scan result } // else go on other code need in method ... }

java android android-intent zxing barcode-scanner

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -