Capture image without permission with Android 6.0

前端 未结 5 1126
庸人自扰
庸人自扰 2021-02-04 07:29

I need to let the user take a picture (from the gallery or from a camera app) with Android 6.0.

Because I don\'t need to control the camera, I wanted to use an intent as

5条回答
  •  无人及你
    2021-02-04 08:16

    Try this:

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File file = new File(getActivity().getApplicationContext().getExternalFilesDir(android.os.Environment.DIRECTORY_PICTURES).getAbsolutePath() + File.separator + "yourPicture.jpg");
    Uri uri = Uri.fromFile(file);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, url);
    

    This gives you access to an "external" storage writable for camera apps in this case, but the files are just visible from your app. To learn a little bit more about storage spaces in android see https://www.youtube.com/watch?v=C28pvd2plBA

    Hope it helps you!

提交回复
热议问题