android - 账户管理器 - "Permission is only granted to system apps"

标签 android android-studio

我正在按照找到的说明进行操作 here at android developer .这些说明说要将这两行代码添加到 list 中:

<manifest ... >
    <uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>

问题是我现在在“ACCOUNT_MANAGER”行上收到一条错误消息,提示“权限仅授予系统应用程序”。

我的应用程序不是系统应用程序,我需要对 OAuth2 服务进行身份验证。任何使用 OAuth2 的应用程序怎么可能需要成为系统应用程序?

有谁知道如何在不要求我的应用程序成为“系统应用程序”的情况下使用 ACCOUNT_MANAGER?

我看过this questionthis question .他们说,对于他们列出的权限,错误是“假”错误消息。有谁知道“ACCOUNT_MANAGER 错误”是否是假消息?我可以像其他帖子中的建议一样告诉编译器忽略它吗?

最佳答案

来自 documentation

String ACCOUNT_MANAGER

Allows applications to call into AccountAuthenticators.

Not for use by third-party applications.

ACCOUNT_MANAGER权限只能授予系统应用

如果您的应用需要 AccountManager,您可以像这样创建一个 AccountAuthenticator 服务 tutorial

或者您可以请求 MANAGE_ACCOUNTS 权限,如 this answer 中所述

MANAGE_ACCOUNTS: The API documentation is not that clear about this permission. But according to Bryans answer, an app can only delete/modify an account it created itself. Of course it can create any new account, and manage that.

关于android - 账户管理器 - "Permission is only granted to system apps",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46823835/

相关文章:

java - Kotlin Cast EditText、TextView 来查看

android - 是否可以在 Android Studio 中运行/调试测试?

Android Studio 第一个项目创建/运行错误(Gradle 未能完成执行)

java - 从 URL 下载 pdf 文件并将其保存在 android (java) 中的特定文件夹中

java - Android 应用程序内存问题

java - 连接到 Java 客户端的 C 服务器套接字问题

android - 错误 :Must have one-pixel frame that is either transparent or white in Android Studio

java - 仅使用 androidTest 代码生成单个 .jar

android - Android加快启动应用程序

android - onConfigurationChanged 第一次没有被调用