Android - take picture - pass uri to camera app

Jake

I am trying to follow this tutorial to invoke the camera app and ask it to save a picture at the uri passed in the intent.

 File image = File.createTempFile("testImage", ".jpg",
              getExternalFilesDir(Environment.DIRECTORY_PICTURES));

 Uri uri = Uri.fromFile(image);

 Intent i = new Intent();
 i.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
 i.putExtra(MediaStore.EXTRA_OUTPUT, uri);

 if (i.resolveActivity(getPackageManager()) != null) {
      startActivityForResult(i, 1);
 }

The path of the image is :

 /storage/emulated/0/Android/data/com.android.test1.app/files/Pictures/testImage-516714791.jpg

I want to ask that how did the camera app have permission to write to this path ? I am testing on Android 4.4, so the path ExternalFilesDir is not publicly writable.

Alex Cohn

The reference says:

There is no security enforced with these files. For example, any application holding WRITE_EXTERNAL_STORAGE can write to these files.

Starting in KITKAT, no permissions are required to read or write to the returned path; it's always accessible to the calling app. This only applies to paths generated for package name of the calling application. To access paths belonging to other packages, WRITE_EXTERNAL_STORAGE and/or READ_EXTERNAL_STORAGE are required.

So, system Camera app, or any other app which is granted WRITE_EXTERNAL_STORAGE permission can write to /storage/emulated/0/Android/data/com.android.test1.app/files/Pictures/.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android camera to take multiple photos

From Dev

Android using front facing camera to take a picture

From Dev

Android - Take picture without preview

From Dev

Android OpenCV - CameraBridgeViewBase take picture?

From Dev

How can we configure the install4j executable to take query parameters provided in the custom uri to take as arguments to pass to the main app

From Dev

Android new Photos app crashes when trying to edit a picture after using the camera

From Dev

Android Camera: Get Picture Uri after the photo is taken

From Dev

How to use flash to take picture on custom camera?

From Dev

android take multiple image with camera

From Dev

Android: take camera picture intent remove confirmation dialog

From Dev

Can we use takePicture() in android without camera preview? I need to take a picture secretly for security purposes

From Dev

Take picture only with android camera intent in Kotlin, not video

From Dev

Take new picture action on Android

From Dev

Rotating picture from android camera

From Dev

Take a camera picture and send it to php server in iPhone

From Dev

Get uri of picture taken by camera

From Dev

Android - take picture - pass uri to camera app

From Dev

Android Tablet Take Picture Camera Intent Activity Restarts

From Dev

Take picture with camera and send with GWT uploader

From Dev

android: camera is not taking a picture

From Dev

ANDROID STUDIO: Take picture with Camera API -> Send this picture to another activity

From Dev

How to use existing camera app(not create one using MediaCapture) and take picture in windows phone 8.1(WinRT)?

From Dev

Take picture with front camera in android service

From Dev

How to use flash to take picture on custom camera?

From Dev

How to take picture or pick image and Pass to a VC

From Dev

Take a picture with react-native-camera

From Dev

Take picture continuously with autofocus in android

From Dev

Android Camera2 : can't take picture with front camera

From Dev

Android: taking a picture without calling local Camera app

Related Related

  1. 1

    Android camera to take multiple photos

  2. 2

    Android using front facing camera to take a picture

  3. 3

    Android - Take picture without preview

  4. 4

    Android OpenCV - CameraBridgeViewBase take picture?

  5. 5

    How can we configure the install4j executable to take query parameters provided in the custom uri to take as arguments to pass to the main app

  6. 6

    Android new Photos app crashes when trying to edit a picture after using the camera

  7. 7

    Android Camera: Get Picture Uri after the photo is taken

  8. 8

    How to use flash to take picture on custom camera?

  9. 9

    android take multiple image with camera

  10. 10

    Android: take camera picture intent remove confirmation dialog

  11. 11

    Can we use takePicture() in android without camera preview? I need to take a picture secretly for security purposes

  12. 12

    Take picture only with android camera intent in Kotlin, not video

  13. 13

    Take new picture action on Android

  14. 14

    Rotating picture from android camera

  15. 15

    Take a camera picture and send it to php server in iPhone

  16. 16

    Get uri of picture taken by camera

  17. 17

    Android - take picture - pass uri to camera app

  18. 18

    Android Tablet Take Picture Camera Intent Activity Restarts

  19. 19

    Take picture with camera and send with GWT uploader

  20. 20

    android: camera is not taking a picture

  21. 21

    ANDROID STUDIO: Take picture with Camera API -> Send this picture to another activity

  22. 22

    How to use existing camera app(not create one using MediaCapture) and take picture in windows phone 8.1(WinRT)?

  23. 23

    Take picture with front camera in android service

  24. 24

    How to use flash to take picture on custom camera?

  25. 25

    How to take picture or pick image and Pass to a VC

  26. 26

    Take a picture with react-native-camera

  27. 27

    Take picture continuously with autofocus in android

  28. 28

    Android Camera2 : can't take picture with front camera

  29. 29

    Android: taking a picture without calling local Camera app

HotTag

Archive