服务启动时广播?
当新服务启动/重新启动时,android 是否发送任何类型的广播。
根本原因是我想在后台服务在我不知情的情况下启动时捕获。
如果有的话,任何关于如何可能的答案都将受到赞赏。
编辑: 我希望它能够与所有服务一起使用,而不仅仅是我自己的服务。
Does android send any kind of broadcast when a new service is started/restarted.
underlying reason is i'd like to catch whenever a background service is starting without my knowledge.
any answer to how it's possible, if it is, are appreciated.
EDIT:
I want it to work with all services, not only my own services.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果后台服务在您的控制范围内,那么您可以使用onBind()方法来了解该服务是由bindService()启动的,同时您可以使用< strong>onStartCommand() 方法(如果服务是通过 startService() 启动的)....
If the background service is in your control then you can use onBind() method to get to know that the service is started by bindService() and same time you can use onStartCommand() method if the service is started by startService()....
这意味着你想访问系统服务还是什么?或者你在你的android应用程序中编写的服务?
如果您想控制您在应用程序中编写的服务,那么如上所述,您可以控制它。或者如果您想在需要时启动或停止服务,那么您可以创建广播接收器并写下onreceive()你想做的事情。
That mean you want to access system service or what? or service which you have written in your android application?
if you want to control your service which you have written in your application then as above told you can control it..or if you want to start or stop service when you want then you can create broadcast receiver and write onreceive() what you want to do.