Peter J. 0 Posted Thursday at 06:16 AM I used this for Delphi 11.x with Android 9. No issue. Now the same code in Delphi 12.1 crashes after I "allow camera" in Android phone. Permissions [x] Camera. I even enabled "Secured File Sharing" just to be safe. Any advice? A similar service for Select Photos From Folder (IFMXTakenImageService) does not crash. Any advice on this? var Params: TParamsPhotoQuery; begin if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService, FCameraService) then begin Params.Editable := False; Params.NeedSaveToAlbum := False; Params.RequiredResolution := TSize.Create(640,640); Params.OnDidFinishTaking := TakePhotoDidFinishTaking; Params.OnDidCancelTaking := DoCancelTaking; FCameraService.TakePhoto(button1, Params); end else begin end; Share this post Link to post
Cristian Peța 107 Posted Thursday at 11:52 AM 5 hours ago, Peter J. said: Now the same code in Delphi 12.1 crashes I suppose you know that Android 9 is not supported by Delphi 12. A log or a message of the error would help to have a better response. Share this post Link to post
Peter J. 0 Posted Thursday at 03:55 PM oh, thanks for the response! I didn't know that Android 9 is not supported. Delphi 12 Athens is here! – Delphi Worlds -> it says Android 8.1 so I'm a little confused. There's no error. click the button to take photo and the app closes. As for the adb log, it is way too many, so I didn't think it would be useful. I'll try to get a newer Android phone. Meanwhile, if anyone has similar experiences, please let me know possible solutions. thank you! Share this post Link to post
Cristian Peța 107 Posted Thursday at 06:47 PM 2 hours ago, Peter J. said: Delphi 12 Athens is here! – Delphi Worlds -> it says Android 8.1 so I'm a little confused. https://docwiki.embarcadero.com/RADStudio/Athens/en/Supported_Target_Platforms Maybe 12.0 supported Android 8.1 but 12.2 not. And if you filter the log only for your app at the and in the last page(s) should be some clues for why app closes. Share this post Link to post
Dave Nottage 572 Posted Thursday at 10:03 PM 10 hours ago, Cristian Peța said: I suppose you know that Android 9 is not supported by Delphi 12. That's "official" support. Theoretically, Delphi 12 can be used to create apps that run on Android 5 or later. 6 hours ago, Peter J. said: There's no error. click the button to take photo and the app closes. Does the camera not appear at all, or is it once you've taken a photo? If the latter, you should show your code for TakePhotoDidFinishTaking. A complete test case would be even better 6 hours ago, Peter J. said: As for the adb log, it is way too many, so I didn't think it would be useful. Just because there's a lot of messages, it does not mean it is not useful. Use filtering to see only relevant messages. This link might help. Share this post Link to post
Peter J. 0 Posted Friday at 12:52 PM 14 hours ago, Dave Nottage said: That's "official" support. Theoretically, Delphi 12 can be used to create apps that run on Android 5 or later. Does the camera not appear at all, or is it once you've taken a photo? If the latter, you should show your code for TakePhotoDidFinishTaking. A complete test case would be even better Just because there's a lot of messages, it does not mean it is not useful. Use filtering to see only relevant messages. This link might help. Thanks for the reply. The camera did not show at all. The app crashed as in "closed without error message". procedure TForm2.DidCancelTaking(const Sender: TObject; const M: TMessage); begin if M is TMessageDidCancelTaking then begin DoCancelTaking; // do cancellation stuff end; end; procedure TForm2.DoCancelTaking; begin //if Assigned(OnDidCancelTaking) then //Memo1.lines.insert(0,'cancel taking photo'); end; procedure TForm2.RequestCameraPermissions; begin PermissionsService.RequestPermissions(['android.permission.CAMERA'], PermissionsResult, nil); end; procedure TForm2.PermissionsResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray); //PermissionsResult begin //if AGrantResults = TPermissionResult.GRANTED then if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then begin // Permissions granted, start the camera // CameraComponent1.Active := True; takephoto(); //TakePhotoFromCameraAction1.Execute; showmessage('executed'); end else begin // Permissions denied, show a message ShowMessage('Camera permission is required to use this feature.'); end; end; procedure TForm2.takephoto(); var Params: TParamsPhotoQuery; begin if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService, FCameraService) then begin Params.Editable := False; Params.NeedSaveToAlbum := False; Params.RequiredResolution := TSize.Create(640,640); Params.OnDidFinishTaking := TakePhotoDidFinishTaking; Params.OnDidCancelTaking := DoCancelTaking; FCameraService.TakePhoto(button1, Params); end else begin end; end; procedure TForm2.TakePhotoFromCameraActionDidFinishTaking(Image: TBitmap); begin Image2.Bitmap.Assign(Image); showmessage('TakePhotoFromCameraActionDidFinishTaking()'); end; Share this post Link to post
Peter J. 0 Posted Friday at 12:52 PM I'm using SDK 34.0 - downloaded from the sdkmanager.bat Share this post Link to post
Dave Nottage 572 Posted Friday at 09:12 PM 8 hours ago, Peter J. said: The camera did not show at all. Have you tried viewing the log messages as per my last reply? Share this post Link to post
Peter J. 0 Posted 20 hours ago Thanks for the reply, Dave. sorry, I've been too overwhelmed to look into the log msg as it seems quite a lot of setup. Anyway, I ran the same code in Android 15 and it worked fine! It's quite disappointing though that it worked in 15 and not 9. How would I know if my app will work on Android 10-14? Surely it's not practical to test all. Share this post Link to post
Dave Nottage 572 Posted 14 hours ago 6 hours ago, Peter J. said: It's quite disappointing though that it worked in 15 and not 9. How would I know if my app will work on Android 10-14? Without the log messages, or a complete, reproducible example, it's going to be hard to tell. Share this post Link to post