Carlos Miller Goncalves de 0 Posted Wednesday at 01:32 PM I have an application developed in Delphi for Android that works offline and manually synchronizes the information from the local database with the cloud database. However, I need a solution that performs this synchronization automatically at regular intervals. I’ve already researched extensively on the subject (such as Android Service, AlarmManager, PowerManager), but without success, as the available information is very vague. Additionally, I will also need to implement location monitoring at defined time intervals, saving the data to the local database and later sending it to the cloud. I need a practical example to implement these functionalities. Share this post Link to post
Dave Nottage 599 Posted Wednesday at 07:13 PM (edited) 5 hours ago, Carlos Miller Goncalves de said: I need a solution that performs this synchronization automatically at regular intervals This kind of background task scenario calls for using a Worker descendant, which is yet to be supported in Delphi. 5 hours ago, Carlos Miller Goncalves de said: I will also need to implement location monitoring at defined time intervals Location monitoring in the background is achievable with Delphi, however capturing location events cannot be at defined time intervals - they occur (oddly enough) when the device location changes. You could however check what the time is when a location update occurs, and if it is close enough to your defined time, take action then. If no location update is available at a defined time it could be assumed that the device is stationary. I had been struggling for some time to implement location updates in the background in a reliable way, however with this latest demo in my Playground repository, it has become the most reliable yet. The next step is to be able to have it start at boot time, which unfortunately in newer versions of Android requires user interaction. Edited Wednesday at 07:15 PM by Dave Nottage 1 Share this post Link to post
alejandro.sawers 15 Posted Wednesday at 08:29 PM Oh, I forgot about this one. I gave up on it last year due to how hard it was to setup and the poor results obtained. I hope to update to 12.3 soon so I can test this too. 1 hour ago, Dave Nottage said: unfortunately in newer versions of Android requires user interaction. Not really an issue for me as my potential users all work in the same company so I can carefully instruct them to properly do this, but yes it can be a challenge for the ordinary Play Store user. 1 Share this post Link to post
Carlos Miller Goncalves de 0 Posted Thursday at 06:27 PM 23 hours ago, Dave Nottage said: This kind of background task scenario calls for using a Worker descendant, which is yet to be supported in Delphi. Location monitoring in the background is achievable with Delphi, however capturing location events cannot be at defined time intervals - they occur (oddly enough) when the device location changes. You could however check what the time is when a location update occurs, and if it is close enough to your defined time, take action then. If no location update is available at a defined time it could be assumed that the device is stationary. I had been struggling for some time to implement location updates in the background in a reliable way, however with this latest demo in my Playground repository, it has become the most reliable yet. The next step is to be able to have it start at boot What would be the suggestion to carry out this data synchronization recurrently, considering obstacles such as: the APK being minimized, the APK being closed, and the device being locked? Share this post Link to post
Dave Nottage 599 Posted Thursday at 07:09 PM 38 minutes ago, Carlos Miller Goncalves de said: What would be the suggestion to carry out this data synchronization recurrently, considering obstacles such as: the APK being minimized, the APK being closed, and the device being locked? If it's just data synchronization, is not user initiated, and you want it in Delphi code, you may be stuck. 1 Share this post Link to post
Carlos Miller Goncalves de 0 Posted Thursday at 11:23 PM 4 hours ago, Dave Nottage said: Se for apenas sincronização de dados, não for iniciada pelo usuário e você quiser isso no código Delphi, você pode ficar preso. The APK I am finalizing and currently testing is designed to collect events entered by the user. In many cases, it serves as a delivery APK. All operations are conducted on the local database of the device, as internet access is not available everywhere, which means it functions primarily offline. The issue is that, to prevent the user from having to sync manually, it would require some feature to enable automatic synchronization. Share this post Link to post