查看我的代码:
doSomeActionWillStartNewIntentToSelectImage();
// check started intent
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
Assert.assertThat(activity, new StartedMatcher(intent));
// simulate the returning result
shadowOf(activity).receiveResult(
new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI),
Activity.RESULT_OK,
new Intent().setData(activity.drawableId2Uri(R.drawable.icon_ok)));
但是会报错:
java.lang.RuntimeException: No intent matches
Intent{action=android.intent.action.PICK, data=content://media/internal/images/media} among
[Intent{action=android.intent.action.PICK, data=content://media/internal/images/media}]
at com.xtremelabs.robolectric.shadows.ShadowActivity.receiveResult(ShadowActivity.java:381)
奇怪的Intent{action=android.intent.action.PICK, data=content://media/internal/images/media}
是和后面的一模一样。
哪里出了问题以及如何解决?