onActivityResult not working with fragments..how to call onActivityResult in a class which extends fragment not fragment activity.Is there any other method similar to onActivityResult in fragments?
onActivityResult not working on fragments
Asked Answered
Please post your code, what have you tried, what errors you get etc... –
Perversion
camera.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //((ApplicationClass)getActivity().getApplication()).setFlagforCameraExpense(true); Intent cameraIntent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); } }); –
Bohman
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case CAMERA_PIC_REQUEST: if (requestCode == CAMERA_PIC_REQUEST) { try { //save the image in an imageview } catch (Exception e) { return; } } break; } } –
Bohman
when iam calling onactivtyresult frm fragment activity its working fine but i want to call this method frm my framnet class..is it possible to do so? –
Bohman
There is issue in support library. Check this post: shomeser.blogspot.com/2014/01/nested-fragments-for-result.html –
Barratry
1. Make sure your code like this:
startActivityForResult(intent,req);
and not this:
getActivity().startActivityForResult(intent,req);
2. Make sure implement your Fragment's onActivityResult:
super.onActivityResult(requestCode, resultCode, data);
© 2022 - 2024 — McMap. All rights reserved.