我使用ZXing来使用条形码阅读器。
它正常工作,直到我将动作栏添加到我的应用程序。(将android-support-v7-appcompat.jar
添加到依赖项)然后当我单击按钮打开条形码扫描仪时:
public void btnBarcode_Click(View view) {
IntentIntegrator.initiateScan(this);
}
我的应用程序退出此日志:
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
是与“android-support-v7-appcompat.jar
”有关还是没有?
答案 0 :(得分: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)
之前我遇到过这个问题,但我几乎记不住了,但我认为你应该挖掘库并更改一个请求代码,该代码在zxing库中启动一个Activity,结果可能大于65535。