0

I used ZXing for using barcode reader. it worked properly until i add actionbar to my app.(add android-support-v7-appcompat.jar to dependencies) and then when i click button to open barcode scanner :

public void btnBarcode_Click(View view) { IntentIntegrator.initiateScan(this); } 

My App exit with this log:

07-20 10:34:03.690: E/AndroidRuntime(23805): FATAL EXCEPTION: main 07-20 10:34:03.690: E/AndroidRuntime(23805): java.lang.IllegalStateException: Could not execute method of the activity 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.view.View$1.onClick(View.java:3606) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.view.View.performClick(View.java:4211) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.view.View$PerformClick.run(View.java:17446) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.os.Handler.handleCallback(Handler.java:725) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.os.Handler.dispatchMessage(Handler.java:92) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.os.Looper.loop(Looper.java:153) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.app.ActivityThread.main(ActivityThread.java:5299) 07-20 10:34:03.690: E/AndroidRuntime(23805): at java.lang.reflect.Method.invokeNative(Native Method) 07-20 10:34:03.690: E/AndroidRuntime(23805): at java.lang.reflect.Method.invoke(Method.java:511) 07-20 10:34:03.690: E/AndroidRuntime(23805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 07-20 10:34:03.690: E/AndroidRuntime(23805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 07-20 10:34:03.690: E/AndroidRuntime(23805): at dalvik.system.NativeStart.main(Native Method) 07-20 10:34:03.690: E/AndroidRuntime(23805): Caused by: java.lang.reflect.InvocationTargetException 07-20 10:34:03.690: E/AndroidRuntime(23805): at java.lang.reflect.Method.invokeNative(Native Method) 07-20 10:34:03.690: E/AndroidRuntime(23805): at java.lang.reflect.Method.invoke(Method.java:511) 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.view.View$1.onClick(View.java:3601) 07-20 10:34:03.690: E/AndroidRuntime(23805): ... 11 more 07-20 10:34:03.690: E/AndroidRuntime(23805): Caused by: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:822) 07-20 10:34:03.690: E/AndroidRuntime(23805): at pl.looksok.listviewdemo.IntentIntegrator.initiateScan(IntentIntegrator.java:179) 07-20 10:34:03.690: E/AndroidRuntime(23805): at pl.looksok.listviewdemo.IntentIntegrator.initiateScan(IntentIntegrator.java:140) 07-20 10:34:03.690: E/AndroidRuntime(23805): at pl.looksok.listviewdemo.IntentIntegrator.initiateScan(IntentIntegrator.java:102) 07-20 10:34:03.690: E/AndroidRuntime(23805): at pl.looksok.listviewdemo.AddNewPerson.btnBarcode_Click(AddNewPerson.java:107) 07-20 10:34:03.690: E/AndroidRuntime(23805): ... 14 more 

is it related with "android-support-v7-appcompat.jar" or no?

1 Answer 1

2
07-20 10:34:03.690: E/AndroidRuntime(23805): Caused by: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode 07-20 10:34:03.690: E/AndroidRuntime(23805): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:822) 07-20 10:34:03.690: E/AndroidRuntime(23805): at pl.looksok.listviewdemo.IntentIntegrator.initiateScan(IntentIntegrator.java:179) 

I was facing that issue before but i can barely remember it but i think you should dig in library and change a request code which starting an Activity for result in zxing library it's probably greater than 65535.

Sign up to request clarification or add additional context in comments.

2 Comments

@mahdi : Trace the initiateScan() function. the error raised at : at pl.looksok.listviewdemo.IntentIntegrator.initiateScan(IntentIntegrator.java:179)
Correct, Android does not allow request codes greater than 65535 due to limitations imposed by the fragment API. You can see the library's default is correctly sized: github.com/zxing/zxing/blob/master/android-integration/src/main/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.