gpt4 book ai didi

android - 如何使用带签名保护的权限?

转载 作者:行者123 更新时间:2023-11-29 00:36:40 25 4
gpt4 key购买 nike

我想了解如何创建主应用程序及其关联的关键应用程序。问题是我不知道如何让关键应用程序将 mainapp.action.VALID 广播到主应用程序中。

@MainApp

<permission
android:name="mainapp.permission.CHECK_RESULT"
android:protectionLevel="signature" />

<application>

<receiver
android:name=".ResponseReceiver"
android:permission="mainapp.permission.CHECK_RESULT" >
<intent-filter>
<action android:name="mainapp.action.CHECK_OK" />
</intent-filter>
</receiver>

@KeyApp

Intent i = new Intent();
i.setAction("mainapp.action.CHECK_OK");
context.sendBroadcast(i, "mainapp.permission.CHECK_RESULT");

结果是, Intent 被拒绝:它需要 mainapp.permission.CHECK_RESULT 权限。但是如果我删除权限,mainapp.receiver.ResponseReceiver 可以接收到 Intent 并且还可以确认两个应用程序使用相同的签名。

我在这里错过了什么?

最佳答案

如 nandeesh 所示,您需要相应的 <uses-permission> KeyApp 中的元素,表示 KeyApp 请求 mainapp.permission.CHECK_RESULT许可。

此外,据我所知,您的第二个参数 sendBroadcast()将要求 MainApp 也有 <uses-permission> mainapp.permission.CHECK_RESULT 的元素.如果那不是你的 Intent (双关语(嵌套双关语(哦,不!无限双关语递归!))),我会把第二个参数放在 sendBroadcast() 上。打电话。

关于android - 如何使用带签名保护的权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12268091/

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