gpt4 book ai didi

android - 调用 bindAppWidgetId 时出现安全异常

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:43:02 25 4
gpt4 key购买 nike

在为 Android 开发启动器(主屏幕)应用程序时,我遇到了一个我不明白的安全异常。

  • 调用[bindAppWidgetId()][1] 方法来自在我的启动器 Activity 中,我得到此安全异常:

08-19 11:30:11.689: 错误/AndroidRuntime(6032): java.lang.SecurityException: bindGagetId appWidgetId=99 provider=ComponentInfo{com.android.music/com.android.music.MediaAppWidgetProvider}: 用户10034没有android.permission.BIND_APPWIDGET。

我最初以为我忘记了 list 中的 BIND_APPWIDGET 权限,但它确实存在。

android api 文档说明了这一点:

"You need the APPWIDGET_LIST permission. This method is to be used by the AppWidget picker."

我尝试添加权限android.permission.APPWIDGET_LIST,但并没有解决问题。

此外,我还从包含 AppWidgetPickActivity 代码的 android 源代码中查看了设置应用程序的 list :有一条特殊的行要求共享用户 ID:

"android:sharedUserId="android.uid.system"

会不会跟我的问题有关?

如果有人有想法那就太好了!

干杯,洛朗

最佳答案

我找到了答案!

BindAppWidgetId() 故意不对应用程序可用! (安全问题)。

"The android.permission.BIND_APPWIDGET permission is a system permission. You can only get that permission if your package is installed as a system package (installed in /system/app in stead of /data/app) or sign you app with a certificate that's the same as your android image. So basicly this means you can only use this permission if you are also the creator of the android image on your platform/phone."

以下是此信息的链接:

http://groups.google.com/group/android-developers/browse_thread/thread/231245ba6d1e690f/047b9d3f776d7e54?lnk=gst&q=bindAppWidgetId#047b9d3f776d7e54

http://groups.google.com/group/android-developers/browse_thread/thread/f24e0f484a79d529/ef84188e8533a125?lnk=gst&q=bindAppWidgetId#ef84188e8533a125

关于android - 调用 bindAppWidgetId 时出现安全异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3520564/

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