我的图书馆项目中有一项活动。从该活动中,我试图从图书馆获取图像。千分之一(隐喻),下面的代码工作正常。但大多数情况下,选择图像后,应用程序会卡在黑屏。
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/* video/*");
startActivityForResult(intent, REQUEST_GALLERY);
日志
这是成功的场景:
06-22 11:22:16.559 19038-19038/com.xyz D/SELECT_IMAGE: onCreate
06-22 11:22:16.869 19038-19038/com.xyz D/SELECT_IMAGE: onResume
06-22 11:22:24.949 19038-19038/com.xyz D/SELECT_IMAGE: Before startActivityForResult
06-22 11:22:24.959 19038-19038/com.xyz D/SELECT_IMAGE: After startActivityForResult
06-22 11:22:32.359 19038-19038/com.xyz D/SELECT_IMAGE: RESULT onActivityResult
06-22 11:22:32.429 19038-19038/com.xyz D/SELECT_IMAGE: onResume
在这之后,我再次尝试,然后只是这两个日志,然后卡住了
06-22 11:23:02.919 19038-19038/com.xyz D/SELECT_IMAGE: Before startActivityForResult
06-22 11:23:02.929 19038-19038/com.xyz D/SELECT_IMAGE: After startActivityForResult
已编辑:我得到的日志adb shell dumpsys activity top
java.lang.IndexOutOfBoundsException: Invalid index 6, size is 3
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.android.server.am.ActivityStack.getDumpActivitiesLocked(ActivityStack.java:6544)
at com.android.server.am.ActivityStackSupervisor.getDumpActivitiesLocked(ActivityStackSupervisor.java:5734)
at com.android.server.am.ActivityManagerService.dumpActivity(ActivityManagerService.java:17777)
at com.android.server.am.ActivityManagerService.dump(ActivityManagerService.java:16936)
at android.os.Binder.dump(Binder.java:334)
at android.os.Binder.onTransact(Binder.java:292)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:2568)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3242)
at android.os.Binder.execTransact(Binder.java:461)