11

现在这很奇怪......

使用

AccountManager.newChooseAccountIntent(null, null, new String[] {"com.google"}, null, null, null, null);

确实给了我一个帐户列表。但是使用

AccountManager.get(context).getAccountsByType("com.google")

返回 0 个帐户。问题只发生在棉花糖中。

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

清单中仍然存在。

有任何想法吗...?

更新:事实证明,必须请求 GET_ACCOUNTS 的许可,即使文档另有说明......(见评论)

4

2 回答 2

8

根据这个 g+ 帖子https://plus.google.com/+BrendonSled/posts/jdrHS3GC7c6权限 GET_ACCOUNTS 现在被列为危险,用户必须允许它

于 2015-08-23T06:39:10.423 回答
3

对于任何来到这里的人来说,真正的答案就在这里

简而言之,您需要使用AccountManager.newChooseAccountIntent()( ref )

于 2018-10-25T12:59:40.280 回答