android – 调用bindAppWidgetId时的安全异常
作者:互联网
在为Android开发Launcher(Homescreen)应用程序时,我遇到了一个我不明白的安全例外.
>打电话的时候
[bindAppWidgetId()] [1]方法来自
在我的启动器活动中,我明白了
此安全例外:
08-19 11:30:11.689:ERROR / AndroidRuntime(6032):java.lang.SecurityException:bindGagetId appWidgetId = 99 provider = ComponentInfo {com.android.music / com.android.music.MediaAppWidgetProvider}:用户10034没有android.permission.BIND_APPWIDGET.
我首先想到我已经忘记了我的清单中的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源代码中的Settings应用程序的清单:有一条要求共享用户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.”
以下是此信息的链接:
标签:android,android-widget,launcher,homescreen 来源: https://codeday.me/bug/20190606/1190071.html