Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);
Intent takePictureIntent = new Intent(getParent(),TakePicture.class);
takePictureIntent.putExtra("image",thumbnail);
OpenBeeActivityGroup opentActivity = (OpenBeeActivityGroup)getParent();
opentActivity.startChildActivity("TakePicture Activity",takePictureIntent);

- 21,853
- 23
- 89
- 133

- 4,235
- 4
- 28
- 49
-
putting on my mind-reading hat... nope, doesn't work :) – denis.solonenko Jul 13 '11 at 10:33
-
but why any reason from your side... – kamal_tech_view Jul 13 '11 at 12:57
-
any any other way to accomplish the task...? – kamal_tech_view Jul 13 '11 at 12:59
-
@kamal_tech_view : hello sir, can you help me to solve this little issue? I'm facing the same issue as yours but can't understand the given solutions here.. – Looking Forward Sep 21 '13 at 08:36
2 Answers
As for I understand from your Question is,
This happen while using ActivityGroup
. Since you are starting Activity
for result inside a child Activity
(i.e TakePicture.class
), and Android will only allow single nested layer of child Activity
(ies) (means child Activity
cannot nest another child Activity
).
And you are probably handling the result in your child Activity
(i.e TakePicture.class
).
So the solution to your problem is to handle that result inside your parent Activity
(OpenBeeActivityGroup
)'s onActivityResult()
and then send your result to the active Activity
.
you will use something like this.
inside your child Activity start your startActivityForResult()
from parent Activity
like.
getParent().startActivityForResult(cameraIntent,Global.CAMERA_PIC_REQUEST);
and inside your onActivityResult()
of ActivityGroup
(OpenBeeActivityGroup
):
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == Activity.RESULT_OK)
{
switch(requestCode)
{
case Global.CAMERA_PIC_REQUEST: // global variable to indicate camera result
Activity activity = getLocalActivityManager().getCurrentActivity();
activity.onActivityResult(requestCode, resultCode, data);
break;
}
}
}

- 1
- 1

- 37,609
- 9
- 103
- 153
-
If there is one more child class from where I would like to start camera intent then also I need to capture onActivityResult on the parent i.e OpenBeeActivityGroup ? – kamal_tech_view Jul 14 '11 at 05:09
-
Yea if you are starting your child `Activity` using `getParent().startChildActivity("AnyString",intent);` then you will handle the result in `OpenBeeActivityGroup` – Adil Soomro Jul 14 '11 at 06:46
-
@Adil... hello sir, can you help me to solve this little issue? – Looking Forward Sep 20 '13 at 10:11
Along these lines, I have tried to start the camera using your code, and if you truly have it nested, then you cannot again call startActivityForResult. What you need to do is extend ActivityGroup to handle starting a child activity for result. I had to figure this out - HTH.

- 734
- 1
- 7
- 30
-
can u please elaborate your answer, how to do this? i have same issue in my app. – N. Nasim Feb 16 '12 at 12:04
-
The first problem is are you using android 4 or not? If you are using 4, you need to add it to fragmentmanager to start the camera activity. If you are not, then the tabcontainer activity has to have a function that serves as a pass through. Tab 1 = Y Tab 2 = Z Manager = X So if you want to call the camera in Y, you need to use the start activity for result in X and then pass the result through back to Y – Jon Mar 04 '12 at 00:00
-
I just switched to 4.0 and it fixed all of my complicated code. I love fragments now! – Jon Apr 26 '12 at 01:35