stuck with getting camera pic when using the tab Activity

前端 未结 2 1565
有刺的猬
有刺的猬 2020-11-27 22:22
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST); 


                  


        
相关标签:
2条回答
  • 2020-11-27 23:03

    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.

    0 讨论(0)
  • 2020-11-27 23:24

    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;
            }
    
        }
    }
    
    0 讨论(0)
提交回复
热议问题