在accountmanager教程中,建议:
如果数组中有多个Account,则应显示
对话框,要求用户选择一个。
最好的方法是什么?我有一个解决方案,但是如果社区中有其他好的例子,这似乎是一种样板代码,可以被其他人共享和轻松重用。

最佳答案

从android 4.0(api级别14)开始,启动活动的意图如下所示,显示account chooser。

Intent intent = AccountManager.newChooseAccountIntent(null, null,
        new String[] { acc_type }, true, null, null,
        null, null);
startActivityForResult(intent, CHOOSE_ACCOUNT);

对于4.0以上的设备,
使用https://github.com/frakbot/Android-AccountChooser

10-05 18:05
查看更多