Anna Blanca 1 Posted September 19 (edited) Hi. I maked sample Android Service, and is's worked normal, but when i added component TTimer on the Android Service form, my app freezed and crashed. What i'm doing wrong? I attach archive whith project of my app, here: Edited September 19 by Anna Blanca Share this post Link to post
ToddFrankson 15 Posted September 19 (edited) https://stackoverflow.com/questions/75470747/delphi-10-4-1-service-in-android-app-with-timer You need to use the native timer to android in a service Edited September 19 by ToddFrankson 1 Share this post Link to post
Dave Nottage 645 Posted September 20 10 hours ago, Anna Blanca said: TTimer on the Android Service form, my app freezed and crashed It's a long standing issue that a service cannot use the FMX.Types unit (directly or indirectly). As per the SO link that Todd referred to, you could use TAndroidTimer from this unit. (which does not use any FMX.xxx units) Share this post Link to post
Anna Blanca 1 Posted September 20 55 minutes ago, Dave Nottage said: Согласно ссылке SO, на которую ссылался Тодд, вы можете использовать TAndroidTimer этого подразделения What's TAndroidTimer? So, I need Indy components too, and TNetHTTPClient, and more other components. Share this post Link to post
Dave Nottage 645 Posted September 20 21 minutes ago, Anna Blanca said: What's TAndroidTimer? It's in the link that you quoted from my reply. 22 minutes ago, Anna Blanca said: I need Indy components too, and TNetHTTPClient, and more other components. Indy and TNetHTTPClient do not use FMX units, so those will be OK. Share this post Link to post
Anna Blanca 1 Posted September 20 10 hours ago, Dave Nottage said: ndy and TNetHTTPClient do not use FMX units, so those will be OK. O'K, but i can't add CameraComponent, how fix it? And why FMX doesn't work in Android Service? Share this post Link to post
Dave Nottage 645 Posted September 20 34 minutes ago, Anna Blanca said: O'K, but i can't add CameraComponent, how fix it? TCameraComponent uses FMX units, so whatever camera functionality you require, you would need to implement it some other way. 35 minutes ago, Anna Blanca said: And why FMX doesn't work in Android Service? There is a report from years ago (actually filed by me) in the old Quality Portal (unfortunately it's not accessible right now, and has not been for a few days) which may have the exact details - it is related to FMX units expecting an Activity instance to be present, but services do not have one. Share this post Link to post
Anna Blanca 1 Posted September 20 10 hours ago, Dave Nottage said: TCameraComponent uses FMX units, so whatever camera functionality you require, you would need to implement it some other way. I'm guessing if it's FMX, but how i can use TCameraComponent in background-mode? Share this post Link to post
Anna Blanca 1 Posted September 20 23 hours ago, Dave Nottage said: As per the SO link that Todd referred to, you could use TAndroidTimer from this unit. (which does not use any FMX.xxx units) So, i must download this LS.AndroidTimer.pas and add it in my project, or what? Share this post Link to post
Dave Nottage 645 Posted September 20 17 minutes ago, Anna Blanca said: 'm guessing if it's FMX, but how i can use TCameraComponent in background-mode? You cannot use TCameraComponent in a service. If you want to use camera features in a service, you'd need to either implement it yourself or have someone do it for you. It might help to explain why you want code to do this. Using the camera in a service means that it cannot be shown in a UI, so presumably you'll want to be able to record to a file, and/or send the video over a network. This is not trivial. 2 minutes ago, Anna Blanca said: So, i must download this LS.AndroidTimer.pas and add it in my project, or what? If you wish to use the code from it, yes. Share this post Link to post
Anna Blanca 1 Posted September 22 On 9/21/2025 at 2:24 AM, Dave Nottage said: so presumably you'll want to be able to record to a file, and/or send the video over a network. This is not trivial. I can make photo and send it on FTP, or something, that's not so complex. Share this post Link to post
Dave Nottage 645 Posted September 22 3 hours ago, Anna Blanca said: I can make photo... 3 hours ago, Anna Blanca said: ..that's not so complex. Given that you'd need to rewrite a significant part of the functionality from TCameraComponent (in order to avoid using FMX units), yes.. it'll be somewhat complex. Share this post Link to post
Dave Nottage 645 Posted September 22 On 9/20/2025 at 10:11 PM, Dave Nottage said: There is a report from years ago (actually filed by me) in the old Quality Portal (unfortunately it's not accessible right now, The old Quality Portal is now accessible. This is a link to the report I was referring to. Share this post Link to post