Android Camera : data intent returns null

前端 未结 11 1692
不知归路
不知归路 2020-11-22 16:20

I have an android application which contains multiple activities.

In one of them I\'m using a button which will call the device camera :

public void         


        
11条回答
  •  渐次进展
    2020-11-22 16:54

    Probably because you had something like this?

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                        
    Uri fileUri =  CommonUtilities.getTBCameraOutputMediaFileUri();                  
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);                        
    startActivityForResult(takePictureIntent, 2);
    

    However you must not put the extra output into the intent, because then the data goes into the URI instead of the data variable. For that reason, you have to take the two lines in the middle out, so that you have

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(takePictureIntent, 2);
    

    That´s what caused the problem for me, hope that helped.

提交回复
热议问题