在服务中测试START_STICKY [英] Test for START_STICKY in a service
问题描述
我有一个包含长期服务的应用程序.我已经从此服务的onStartCommand方法返回了START_STICKY.现在,我想测试START_STICKY是否正常工作.因此,我该如何测试由于内存较少而我的服务被android操作系统杀死并由android操作系统重新启动并再次调用onStartCommand方法的情况.我不能等待几个小时来测试这种情况.请提出一条出路.
I have an app which consists of a long running service. I have returned START_STICKY from onStartCommand method of this service. Now i want to test whether START_STICKY is working properly or not. So how can i test the scenario that my service is killed by the android OS due to less memory and it is restarted by the android OS and onStartCommand method is called again. i cannot afford to wait for hours to test this scenario. Please suggest a way out.
推荐答案
您可以尝试从DDMS中终止该进程.在这种情况下,操作系统可能会重新启动它.
You could try killing the process from DDMS. The OS might restart it in that case.
这篇关于在服务中测试START_STICKY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!