Android Background Service in Delphi XE5

I need to write some service for Android using delphi XE5 (firemonkey) . This service should start in backgroung and periodically read sms inbox, writing it to sqllite DB (see Backup).

I know how to read SMS and how to write it in the database, but I have no idea how to make the application work in the background as a service.

Any ideas?

PS: Thanks for your answers. PPS: Sorry for my bad English.

+6
source share
2 answers

You cannot do this with XE5 only, but you can do it with a little help from Java.

Brian Long published a bipartisan theme:

http://blog.blong.com/2013/11/delphi-and-android-services.html

http://blog.blong.com/2013/11/delphi-and-android-services-part-2.html

+4
source

Android services are not the same as Windows services. If you use the Android service, it still works in the main application of your application. They stop when the device goes into sleep mode. In addition, the system can complete maintenance in low memory conditions and possibly in other situations.

From the documentation:

Typically, a running service performs one operation and does not return the result to the caller. For example, it can upload or download a file over the network. When the operation is completed, the service should stop.

and

"if the service has been running and working for a long time, the system will lower its position in the list of background tasks over time and the service will become very susceptible to killing"

Instead of services, AlarmManager may be the best choice. This is a system service that will perform actions when you say, for example, periodically.

0
source

All Articles