Android background service in Delphi XE5

会有一股神秘感。 提交于 2019-11-30 05:09:02

问题


I need to write some service for android, using delphi XE5 (firemonkey). That service need to run in backgroung and periodically read sms inbox, writing it into sqllite DB (sms backup).

I know how to read sms and how to write it to DB, but I have no idea how to make app work in background as service.

Any ideas?

P.S.: Thank you for your answers. P.P.S.: Sorry for my bad english.


回答1:


You cannot do that with XE5 alone but you can do it with a little help from Java.

Brian Long has published a two-parter on this topic:

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

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




回答2:


Android services are not the same as Windows services. If you do use an Android service, it still runs in your application's main thread. They stop when the device enters sleep mode. Also, the system can terminate the service in low memory and possibly other situations.

From the documentation:

Usually, a started service performs a single operation and does not return a result to the caller. For example, it might download or upload a file over the network. When the operation is done, the service should stop itself.

and

"if the service was started and is long-running, then the system will lower its position in the list of background tasks over time and the service will become highly susceptible to killing"

Instead of services, the AlarmManager might be a better choice. That is a system service, which will execute actions when you'll tell, for example periodically.



来源:https://stackoverflow.com/questions/20467360/android-background-service-in-delphi-xe5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!