Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(came开发者_开发百科raIntent,CAMERA_PIC_REQUEST);
Intent takePictureIntent = new Intent(getParent(),TakePicture.class);
takePictureIntent.putExtra("image",thumbnail);
OpenBeeActivityGroup opentActivity = (OpenBeeActivityGroup)getParent();
opentActivity.startChildActivity("TakePicture Activity",takePictureIntent);
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;
}
}
}
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.
精彩评论