If you can't use onActivityResult then there's a solution that may work for you.
Create a second Activity aka (PickImageActivity)
Store a ResultReceiver as argument in the Intent
Start the startActivityForResult from that Activity onCreate
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
In the onActivityResult you have something like this:
Bitmap received = BitmapFactory.decodeStream(getContentResolver().openInputStream(data.getData()));
Bundle result = new Bundle();
result.putParcelable(RESULT_KEY, received);
((ResultReceiver) getIntent().getParcelableExtra(RECEIVER_KEY)).send(RESULT_OK, result);
finish();
So you may start it like:
Intent pickImage = new Intent(this, PickImageActivity.class);
pickImage.putExtra(RECEIVER_KEY, new ResultReceiver() {
public void onReceive(int resultCode, Bundle data) {
//Work with the data received here trough RESULT_KEY
}
});
If Bitmaps dont fit your memory do send the content file path.
This solution does work and I had implemented it in a project but refactored for activityResult cause if the previous Activity is destroyed you will not receive the Data