Take Picture will use the android api to capture photo while the take preview picture will capture the image in the view or arrangement
So how do I actually access the image after calling TakePreviewPicture? What goes inside the SavedPhoto event to actually display the captured photo in the view?
Use the set Image1.Picture to ProCamera1.Output.
If you want the image to be shown in your Gallery, set the output path to a shared directory and in the ProCamera1.SavedPicture use TaifunTools.GalleryRefresh for ProCamera1.Output.
When I do that, I get an undefined error, and the app crashes.
Here's the actual code blocks I have implemented.
What have you set as the output path Adi ?
Shared Directory - This directory is available to all your app. The Shared directory for pictures is
/storage/emulated/0/Picturesto use it as an output path, make a global variable named
directory, that stores the value
/storage/emulated/0/Pictures/(remember the last
/in this case). On the Button click event, (for the Camera button), set the output path to
filename.png. You should also have a global variable named
lastPath, set its value to ProCamera1.Output. Now use the ProCamera.TakePreviewPicture.
Under the SavedPhoto event, set Image1.Path to
Wait till I post an aia.
App Specific Directory (ASD) - This directory is available to only your app. It is located in the external storage. (I'm not taking about the removable micro SD Card.) If you use this, you may not be able to show the image in your gallery directory from that folder.
App Private Directory (Data directory) - It is where the data for an app is stored. If you want further descriptions on android data storage, read this topic :
Here you go :
Test.aia (45.3 KB)
Tested in compiled apk. (I think it should work in companion too.)
Show also (always) the blocks.
Here they are:
- Why is there no
- Why are you requesting storage permissions on all Android versions (also on Android 11+)?
- Btw, if you request / grant
READis granted implicitily (automatically).
If I use the PermissionGranted event to initialize the camera, the camera will be initialized only once. From the next time the event won't be triggered. So I used a clock which gives 5 seconds to the user to give the permission.
That would require extra off-topic work. The person was after saving and viewing the image, not after the permissions.
No, you just have to use the right blocks.
Storage permissions are not required on Android 11+ for one of the
Shared folders (like
I know that you mean saving permission data in TinyDB, right ?
But that shouldn't matter, I was just after solving the image saving problem.
Would the app crash if I request the permission ? (I don't actually know.)
Why should it? But it's just unnecessary. You should always request as few permissions as possible! I've pointed this out often enough.
Is it possible to save the output as png and not jpg?
The Procam extension saves to jpg by default. You can convert it using this extension:
How I have to put image or image sprite on camera view?
Use the AddComponent block to place an arrangement on the camera view, then you can put whatever you want inside the arrangement, and it will display in the camera view.
Compliments to a very powerful extention!
Is any possibility to take the coordinates of the smartphone screen pixel where the user touched the screen (when the .Touched event was fired or by any other workaround)?
Use your location sensor to return coordinates
I adjusted my question - i was speking about screen coordinates in pixel
If you place a canvas in your arrangement (to fill it) and set background to none, you can get the x,y coordinates from a touch event. You would then need to "translate" these x,y coordinates to match the actual pixel positions in the camera view (if these are different)