gpt4 book ai didi

android - bindService 将客户端限制为特定应用

转载 作者:行者123 更新时间:2023-11-29 23:24:53 24 4
gpt4 key购买 nike

我需要一种方法来限制对特定应用程序的服务使用。也就是说,我有一个包含用户可以安装的服务的应用程序和一个配套应用程序。我只希望配套应用能够使用该服务。我使用 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, and false if not. When the value is false, only components of the same application or applications with the same user ID can start the service or bind to it.

关于android - bindService 将客户端限制为特定应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53751935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com