Z Zvi Member Licensed User Longtime User Nov 27, 2018 #1 I used the CameraEx example and it works perfectly, except that it doesn't save the image to my phone (Redmi Note4). The relevant sub in the example is given as: Sub Camera1_PictureTaken (Data() As Byte) Dim filename As String = "1.jpg" Dim dir As String = File.DirInternal camEx.SavePictureToFile(Data, dir, filename) camEx.StartPreview 'restart preview ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(dir, filename), True) End Sub The image directory on my android is: "\SanDisk SD card\DCIM\Camera\" and the book "B4A Rapid Android App..." states "the image will be stored in the folder /mnt/sdcard/DCIM/Camera. How should I modify the sub "PictureTaken" to save the image?
I used the CameraEx example and it works perfectly, except that it doesn't save the image to my phone (Redmi Note4). The relevant sub in the example is given as: Sub Camera1_PictureTaken (Data() As Byte) Dim filename As String = "1.jpg" Dim dir As String = File.DirInternal camEx.SavePictureToFile(Data, dir, filename) camEx.StartPreview 'restart preview ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(dir, filename), True) End Sub The image directory on my android is: "\SanDisk SD card\DCIM\Camera\" and the book "B4A Rapid Android App..." states "the image will be stored in the folder /mnt/sdcard/DCIM/Camera. How should I modify the sub "PictureTaken" to save the image?
MarkusR Well-Known Member Licensed User Longtime User Nov 27, 2018 #2 DirInternal sounds not like a camera folder use Code: Copy Log(dir) at my android 5.x device its /data/data/com.rauch.test/files its contains the app package name Last edited: Nov 28, 2018 Upvote 0
DirInternal sounds not like a camera folder use Code: Copy Log(dir) at my android 5.x device its /data/data/com.rauch.test/files its contains the app package name
Erel B4X founder Staff member Licensed User Longtime User Nov 28, 2018 #3 Please use [code]code here...[/code] tags when posting code. Adding an image to the phone gallery: https://www.b4x.com/android/forum/threads/show-image-in-gallery-android-7-0.97662/#post-615939 Upvote 0
Please use [code]code here...[/code] tags when posting code. Adding an image to the phone gallery: https://www.b4x.com/android/forum/threads/show-image-in-gallery-android-7-0.97662/#post-615939
Z Zvi Member Licensed User Longtime User Nov 28, 2018 #4 Really appreciate it... this is the only way I can learn by struggling through. Thanks for the rope to pull myself up!! Upvote 0
Really appreciate it... this is the only way I can learn by struggling through. Thanks for the rope to pull myself up!!
Z Zvi Member Licensed User Longtime User Nov 30, 2018 #5 I tried to implement the code example. I called the file "1.jpg" and the directory "\DCIM\Camera". But when I take a picture the app shuts down. Debugging and log errors show the problem at line 126 of CameraExClass: Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) Error: java.io.FileNotFoundException: \DCIM\Camera/1.jpg: open failed: ENOENT (No such file or directory) Dir is "\DCIM\Camera" and FileName is 1.jpg so I don't understand why it tries to open "\DCIM\Camera/1.jpg" instead of "\DCIM\Camera\1.jpg" Any help would be greatly appreciated. Attachments Camera_Example.zip Camera_Example.zip 13.3 KB · Views: 516 Upvote 0
I tried to implement the code example. I called the file "1.jpg" and the directory "\DCIM\Camera". But when I take a picture the app shuts down. Debugging and log errors show the problem at line 126 of CameraExClass: Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) Error: java.io.FileNotFoundException: \DCIM\Camera/1.jpg: open failed: ENOENT (No such file or directory) Dir is "\DCIM\Camera" and FileName is 1.jpg so I don't understand why it tries to open "\DCIM\Camera/1.jpg" instead of "\DCIM\Camera\1.jpg" Any help would be greatly appreciated.
Z Zvi Member Licensed User Longtime User Nov 30, 2018 #6 I have also tried modifying Dir to "/DCIM/Camera" but still get: Error: java.io.FileNotFoundException: /DCIM/Camera/1.jpg: open failed: ENOENT (No such file or directory) Upvote 0
I have also tried modifying Dir to "/DCIM/Camera" but still get: Error: java.io.FileNotFoundException: /DCIM/Camera/1.jpg: open failed: ENOENT (No such file or directory)
MarkusR Well-Known Member Licensed User Longtime User Nov 30, 2018 #7 i guess this folder name is wrong https://www.b4x.com/android/forum/threads/saving-a-picture-to-the-gallery.99412/ https://www.b4x.com/android/forum/threads/save-photo-in-gallery.97887/ Last edited: Nov 30, 2018 Upvote 0
i guess this folder name is wrong https://www.b4x.com/android/forum/threads/saving-a-picture-to-the-gallery.99412/ https://www.b4x.com/android/forum/threads/save-photo-in-gallery.97887/
Z Zvi Member Licensed User Longtime User Nov 30, 2018 #8 When I connect my phone to my laptop the external directory (SD card) of my phone shows directory DCIM which contains the Camera directory. Attachments Screenshot - 30-Nov-18 , 13_52_18.png 131.4 KB · Views: 528 Upvote 0
When I connect my phone to my laptop the external directory (SD card) of my phone shows directory DCIM which contains the Camera directory.
MarkusR Well-Known Member Licensed User Longtime User Nov 30, 2018 #9 try RuntimePermissions.GetAllSafeDirsExternal Code: Copy Sub Process_Globals Dim rp As RuntimePermissions Code: Copy Log(rp.GetSafeDirDefaultExternal("")) https://www.b4x.com/android/forum/t...al-not-the-path-of-the-sd-card.75396/#content https://www.b4x.com/android/forum/pages/results/?query=sd+card Upvote 0
try RuntimePermissions.GetAllSafeDirsExternal Code: Copy Sub Process_Globals Dim rp As RuntimePermissions Code: Copy Log(rp.GetSafeDirDefaultExternal("")) https://www.b4x.com/android/forum/t...al-not-the-path-of-the-sd-card.75396/#content https://www.b4x.com/android/forum/pages/results/?query=sd+card