如何模拟被Android系统杀死的服务 [英] How to simulate a service killed by the Android system

查看:399
本文介绍了如何模拟被Android系统杀死的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中,我想测试系统终止服务的情况.这是因为在Android Wear与掌上电脑之间进行通讯时,我失去了连接.而且我认为这与系统终止某些服务有关.

While developing I wanted to test the situation where the system kills a service. This is because I'm loosing connection when communicating between the Android Wear and the handheld. And I think that it is related with the system killing some services.

有人对如何解决这个问题有建议吗?

Does anyone have a suggestion on how to approach this?

推荐答案

如果您是在Android Wear端运行应用程序时在Android Studio中进行开发,请尝试点击控制台中显示的kill按钮.

if you're developing in Android Studio while you are running your application in android wear side try to hit the kill button displayed in the console.

点击此按钮时,该应用程序的所有线程,服务和活动都将被销毁.如果您的服务类型为"STICKY",则在您终止应用程序后它将自动启动.

When you hit this button all the threads + services + activities from this app will be destroyed. If your service is of type "STICKY" it will start by itself after you kill your application.

这篇关于如何模拟被Android系统杀死的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆