I've an activity register that have fragment container as viewpager using fragmentpageradapter. this kinda like a wizzard form with next and prev button .
In second fragment inside pager i try to get image from gallery with this code :
private void getAvaFromGallery() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), RESULT_LOAD_IMAGE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode,data);
if(resultCode == getActivity().RESULT_OK) {
if (requestCode == RESULT_LOAD_IMAGE) {
CompressBitmap cb = new CompressBitmap(getActivity());
selectedImageUri = cb.handleImageUri(data.getData());
String filepath = cb.getFilename();
bitmap = cb.compressImage(cb.getRealPathFromURI(getActivity(), selectedImageUri), filepath);
photo.setImageBitmap(bitmap);
Log.d("FilePath", filepath);
}
}
}
after getting data , i try to compress it into png and put it into imageview. but i think onactivityresult is not called in this case.
i've try with only fragment inside activity and this is work . but in my case fragment is inside fragment with pager adapter.
i hope someone can help me ..