权限不起作用
我在 Android 中遇到了一些奇怪的权限问题。我试图获取特定用户拥有的谷歌日历列表,但首先我需要让他们选择帐户。
我在清单中包含了这一行:
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
但是我收到此错误:
12-26 03:26:31.004 13841 13841 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{....}: java.lang.SecurityException: caller uid 10105 lacks any of android.permission.GET_ACCOUNTS
我尝试了类似的方法来使用 READ_CALENDAR
和 WRITE_CALENDAR
访问未记录的日历 API,但我有类似的例外(尽管可能出于不同的原因 - 我认为可能值得一提,以防万一)。
请告诉我我做错了什么!
谢谢!
I've been having some odd problems with permission in Android. I am trying to just get a list of the google calendars a particular user has, but first I need to let them pick the account.
I included this line in my manifest:
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
However I get this error:
12-26 03:26:31.004 13841 13841 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{....}: java.lang.SecurityException: caller uid 10105 lacks any of android.permission.GET_ACCOUNTS
I had tried something similar with gaining access to the undocumented Calendar API with READ_CALENDAR
and WRITE_CALENDAR
, but I had similar exceptions (although probably for different reasons - I thought it might be worth mentioning in case it wasn't).
Please clue me in on what I'm doing wrong!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
位于错误的位置(应该是
的子项和
的对等项 code>) 或GET_ACCOUNTS
不是 SDK 应用程序可以持有的权限。该文档对于指示哪些权限适合或不适合 SDK 应用程序的内容非常糟糕。Either your
<uses-permission>
is in the wrong place (should be a child of<manifest>
and a peer of<application>
), orGET_ACCOUNTS
is not a permission that SDK applications can hold. The documentation is singularly lousy about indicating which permissions are and are not eligible for SDK applications.也有同样的问题,将 AndroidManifest.xml 中的目标 SDK 版本更改为更高版本 (19)。在我的例子中,清单中的目标 SDK 版本是 17,相当于 Android 4.2.2,这又与我的 HTC One 上的版本匹配。然而,更改后,联系人的 Phonegap 插件就可以工作了。
Had the same problem as well, changed the target SDK version in the AndroidManifest.xml to a higher version (19). In my case the target SDK version in the manifest was 17, which is equivalent to Android 4.2.2, which in turn matched the version on my HTC One. However after changing it, the Phonegap plugin for contacts worked.