Reputation: 79
I have an Activity inside a ActivityGroup. I have the code to get the image:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_PICK);
The view to pick the picture is launched and I can select an image. But when it goes back to my app, the onActivityResult is never called (neither in the ActivityGroup nor in the Activity).
I have checked several questions just in case I was missing a receiver and I found this Pick an image from the Gallery . But all the flags seem to be off.
Does anyone know what the problem might be? Thank you very much.
Upvotes: 0
Views: 293
Reputation: 6380
There could be an issue related to the layers of Activies here.
The parent activity should call startActivityForResult, so inside the activity launching the image picker use this instead
getParent().startActivityForResult(intent, IMAGE_PICK);
The ActivityGroup should then receive the onActivityResult event. Use the LocalAreaManager to then pass the event to the activity.
if (YourActivityName.class.equals(getLocalActivityManager().getCurrentActivity()){
getLocalActivityManager().((YourActivityName) getCurrentActivity()).handleOnActivityResult(requestCode, resultCode, data);
}
Then inside your activity, create a static class called handleOnActivityResult where you will handle the activity result.
Upvotes: 2