替代完成()方法用于服务类?杀死它死了 [英] alternative to finish() method for Service class? To kill it dead
本文介绍了替代完成()方法用于服务类?杀死它死了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用该方法完成()前几次活动没有任何问题。
I have used the method finish() before in several activities without problems.
当我试图把它叫做广播接收机我从编译器的错误信息里面那个法完成()是未定义的类型AudioService
however when I tried to call it inside of the broadcast receiver I get the error message from the compiler that "the method finish() is undefined for the type AudioService"
AudioService是我服务类的在我的Android应用程序的名称。
AudioService is the name of my Service class in my Android app.
如果有一个服务比我有什么可以打电话杀死这个服务死无完成()方法?
If there is no finish() method in a Service than what can I call to kill this Service dead?
推荐答案
使用此行:
this.stopSelf();
要杀死自己。
或者从境外使用 stopService(意向);
to kill itself.
Or from outside use stopService(intent);
这篇关于替代完成()方法用于服务类?杀死它死了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文