What does android:enabled mean for a service?

你说的曾经没有我的故事 提交于 2019-11-30 04:45:18

问题


What does android:enabled mean for a service? The description says it's whether it can be instantiated by the system. What does that mean? Can it be used at all? Can it only be used locally? If you can use a "disabled" service in some way then how do you start it? If it can't be used at all then what in the world is the point? Can't you just comment out the service tag instead?

I was looking into creating a service that isn't to be used by other applications. Not sure if adroid:enabled can be used for this purpose.


回答1:


What does that mean?

It means whether it can run.

Can it be used at all?

Not if it is disabled.

Can it only be used locally?

Not if it is disabled.

If it can't be used at all then what in the world is the point?

android:disabled is effectively inherited, and it definitely has use cases for activities and BroadcastReceivers. In the case of a service, it would be less likely to be used, but might still have merit (e.g., an API for third parties that the user can opt out of).

Can't you just comment out the service tag instead?

Java code cannot do that at runtime. The value of android:enabled, however, can be modified through PackageManager at runtime.



来源:https://stackoverflow.com/questions/9284774/what-does-androidenabled-mean-for-a-service

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