[SOLVED] CustomCamera taking dark photons lazarus / 43-Android ---------------------------------------------------------------------- hongdusocal · 2023-06-26 22:12 I am new to LAMW. I am trying to use CustomCamera to take photons. After CustomCamera1.TakePiture() is called, the CustomCamera1PictureTaken event is triggered in about three seconds, but the returned image is totally dark. Meanwhile the preview doesn't show anything either. I didn't process the JNIPrompt and OnActivityResult events at all. What should I do to get images from either front or back cameras? Thanks. ---------------------------------------------------------------------- jmpessoa · 2023-06-28 18:42 Hi, hongdusocal! What about demo  "AppCustomCameraDemo1" ? It's working? ---------------------------------------------------------------------- hongdusocal · 2023-06-28 23:36 Thanks jmpessoa for your informative response. I didn't realize that there are AppCustomCameraDemo files in  the onlinepackagemanager folders. I give them a try. Here is my progress: I checked projects located in fpc-lazarus/ccr folders. I tried one with AppCameraDemo2, it has jCamara object and it works well but user has to click the button to accept picture. I couldn't open AppCameraDemo project because of some error messages that I cannot clear.  I tried both in linux and Windows, the results are similar. So I played with CustomCamera component for a while. I later found that the CustomCamera object has a small preview-like window that must be made visible to function; however, it shows nothing when TakePicture is called. The PictureTaken event does get triggered and saves a full sized photo by the name of fullPath. That is great, even without processing the permission events, photo can be taken. However, I cannot use the picture because it is too large after I pull it to local computer from the phone and examine the content. Maybe the file is not readable to Bitmap objects. I also used Bitmap.getResizedBitmap(0.1,0.1), this won't work for the ImageView either.  I tried to load the fullPath using ImageView, not working; tried loading fullPath using Bitmap object and sending to ImageView, not working either. I will try the demo you pointed out to me. Thanks, Hong ---------------------------------------------------------------------- jmpessoa · 2023-06-29 06:09 QuoteI didn't realize that there are AppCustomCameraDemo files in  the onlinepackagemanager folders... Please get the LAMW packages from "github", so you will always be up to date... REF.: https://github.com/jmpessoa/lazandroidmodulewizard ---------------------------------------------------------------------- hongdusocal · 2023-06-29 16:29 Thanks again for the link. I will pull files from the github in the future. I did try the AppCustomCameraDemo1 you referred to and everything works as expected.  I then tried to build a similar app from scratch. I found some interesting things. The preview can go live even no permission request events are configured, but it is very tricky because if I put an ImageView on the app, the preview will not go live. The camera always takes picture and saves the original sized photo (4160x3120 in my case) without handling the permission requests. I have to learn more about how to arrange the widgets on the phone and what affects they have on each other and also how to access files on the phone. Thanks, Hong ---------------------------------------------------------------------- hongdusocal · 2023-06-30 18:59 I tried the code on phones and a tablet and have some new findings. ImageFileManager is required for loading saved photo. The tablet prompts for camera and file folder access, these events must be processed. But for the very old android phone, PictureTaken event is never triggered. Don't know how to get the photos. ---------------------------------------------------------------------- hongdusocal · 2023-07-01 23:13 I still cannot make the old android phones take picture by calling CustomCamera1.TakePicture or TakePicutre('photo1.jpg'). I have spent quite a few hours. CumstomCamera1.getImage didn't return anything either. I have tried to set the path to accessible folders, implementing all events, the PictureTaken event  simply will not trigger. The alternative Camera widget works, but it invokes the android camera interface and button must be clicked to accept the photo. Not sure why the code works for some androids but not for others. Is there a work around? Any help is highly appreciated. Hong ---------------------------------------------------------------------- hongdusocal · 2023-07-08 07:45 Finally found the problem. The start camera preview and stop camera preview calls in the jCustomCamera source code need to be commented out for this specific phone. It might have raised exceptions so that the intent data was never processed and saved to phone. Hope this can help others. Hong