stuck with getting camera pic when using the tab Activity

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);     

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

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;
        }

    }
}

Solution 2

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.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply