我需要一种方法来限制对特定应用程序的服务使用。也就是说,我有一个包含用户可以安装的服务的应用程序和一个配套应用程序。我只希望配套应用能够使用该服务。我使用 bindIntent
调用该服务。
我一直在查看客户端的包是否是传递给 onBind
的 Intent 的一部分,但没有看到。在服务中,有没有办法获取客户端的包?
是否有任何其他方法来识别不能被欺骗的客户端应用程序?我可以在服务 list 中添加什么吗?
最佳答案
service Manifest.xml
中的元素可用于控制:
<service
...
android:exported="false" />
Whether or not components of other applications can invoke the
service
or interact with it —true
if they can, andfalse
if not. When the value isfalse
, only components of the same application or applications with the same user ID can start theservice
or bind to it.
关于android - bindService 将客户端限制为特定应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53751935/