使用ACRA时Android的例外情况

use*_*076 0 android android-activity start-activity

我的应用程序使用ACRA进行错误报告,我的设备中有一些报告有错误:只能使用低16位的requestCode ..谷歌显示使用startActivityForResult时发生此错误,但我搜索了我的代码几次,我不会在任何地方打电话.

我很困惑,我想知道这是如何影响用户的(有趣的是,Crash Reports beta根本没有显示任何错误).

其他人遇到这个?

java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}:  
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.support.v4.app.g.startActivityForResult(SourceFile:690)
at com.android.e.a.a(Unknown Source)
at com.android.e.e.a(Unknown Source)
at com.android.o.e.a(Unknown Source)
at com.android.o.b.a(Unknown Source)
at com.android.framework.context.d.a(Unknown Source)
at com.android.framework.context.d.onResume(Unknown Source)
at com.android.Kiwi.onResume(Unknown Source)
at com.myapp.MyActivity.onResume(SourceFile)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
... 10 more
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.support.v4.app.g.startActivityForResult(SourceFile:690)
at com.android.e.a.a(Unknown Source)
at com.android.e.e.a(Unknown Source)
at com.android.o.e.a(Unknown Source)
at com.android.o.b.a(Unknown Source)
at com.android.framework.context.d.a(Unknown Source)
at com.android.framework.context.d.onResume(Unknown Source)
at com.android.Kiwi.onResume(Unknown Source)
at com.myapp.MyActivity.onResume(SourceFile)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

有人可以帮我吗?

Rag*_*ood 8

来自FragmentActivity源代码:

/**
* Modifies the standard behavior to allow results to be delivered to fragments.
* This imposes a restriction that requestCode be <= 0xffff.
*/
@Override
public void startActivityForResult(Intent intent, int requestCode) {
    if (requestCode != -1 && (requestCode&0xffff0000) != 0) {
        throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
    }
    super.startActivityForResult(intent, requestCode);
}
Run Code Online (Sandbox Code Playgroud)

似乎你的请求代码只能达到0xffff,这转化65535为我们基地10个痴迷的人类.