onActivityResult not working on fragments
Asked Answered
B

1

1

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?

Bohman answered 25/9, 2013 at 12:40 Comment(5)
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.htmlBarratry
E
0

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);
Elviselvish answered 28/10, 2013 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.