Creating an android service to run in the background using python

感情迁移 提交于 2019-12-11 13:19:32

问题


I would like to know if it is possible to run an android service in the background (and possibly on boot) without rooting the device, using python and sl4a and if so how would i go about doing that.


回答1:


For running a service in background or on boot you have to define a Broadcast Receiver which will basically start the service.

Please refer code snippets mentioned in the answer of below question.

Android BroadcastReceiver on startup - keep running when Activity is in Background

I have seen some information about developing in python on pythoncentral but I have never developed a service using python/sl4a.




回答2:


If anyone is looking for a python for android (p4a) solution:

  • http://python-for-android.readthedocs.io/en/latest/services/

python-for-android supports the use of Android Services, background tasks running in separate processes. These are the closest Android equivalent to multiprocessing on e.g. desktop platforms, and it is not possible to use normal multiprocessing on Android. Services are also the only way to run code when your app is not currently opened by the user.



来源:https://stackoverflow.com/questions/25410562/creating-an-android-service-to-run-in-the-background-using-python

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