是否有 API 可以知道特定服务是否允许绑定?

发布于 2024-12-12 11:11:08 字数 179 浏览 3 评论 0原文

我正在开发一个尝试与服务绑定的应用程序,但它失败了,因为它尝试绑定的服务未导出以供其他应用程序绑定。这让我想到是否有一种方法可以事先知道指定的服务类是否以编程方式接受绑定。

我知道通过检查 AndroidManifest.xml 的元素会建议导出= false还是true。但我想通过 API 调用或类似的东西来了解同样的情况。

I am working on a app which tries to bind with a service, but it fails to do so because service it is trying bind is not exported for other apps to bind. This made me think if there is a way to know before hand if a specified service class accepts binding or not programmatically.

I know by checking element of AndroidManifest.xml will suggest if exported = false or true. But I want to know the same by a API call or something like that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-12-19 11:11:08

抱歉,ServiceRecord 包含此导出的信息,Android 没有提供这些信息获得访问权。

最好的办法是在尝试绑定到服务时检查SecurityException

Sorry, ServiceRecord contains this exported' information, which Android has provided no way of getting access to.

Your best bet is to check for a SecurityException when you try to bind to the Service.

ζ澈沫 2024-12-19 11:11:08

可能不是您想听到的,但实际上应该假设您不允许绑定到服务,除非应用程序 API 显式公开它。

Probably not what you want to hear, but should really just assum you're not allowed to bind to a service unless the apps API explicitly exposes it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文