Android camera intent FileUriExposedException for SDK >= 24

后端 未结 2 605
小鲜肉
小鲜肉 2021-02-05 16:11

I use this code to get a picture from camera and put it on imageview:

  private void openCamera()
{
    mMediaUri =getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

             


        
2条回答
  •  梦如初夏
    2021-02-05 16:42

    It can be done as simple as below . Put these 2 lines in onCreate of your activity.

    StrictMode.VmPolicy.Builder newbuilder = new StrictMode.VmPolicy.Builder();
    StrictMode.setVmPolicy(newbuilder.build());
    

    URI exposure will be ignored by Vm I resolved my issue so.

提交回复
热议问题