现在这很奇怪......
使用
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 的许可,即使文档另有说明......(见评论)