的AccountManager:如何让用户选择使用一个对话框账户 [英] AccountManager: How to let the user select an Account using a Dialog

查看:410
本文介绍了的AccountManager:如何让用户选择使用一个对话框账户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在的AccountManager教程记住您的用户,我们建议:

In the AccountManager tutorial Remembering Your User, it's recommended:

如果有多于一个的数组中的帐户,你应该present一个   对话框,要求用户选择之一。

If there's more than one Account in the array, you should present a dialog asking the user to select one.

什么是做到这一点的最好方法是什么?我心里有一个解决方案,但如果有来自社区其他很好的例子,它看起来这是什么样的样板code可以分享和轻松地重新被别人利用。

What's the best way to do this? I have a solution in mind, but if there are other good examples from the community, it seems like this is the kind of boilerplate code that could be shared and easily re-used by others.

推荐答案

从Android 4.0的(API级别14)日起,推出如下所示意图的活动,显示帐户选择。

From Android 4.0 (API level 14) onwards, launching an activity with an intent shown below, shows 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

For devices older than 4.0,
use https://github.com/frakbot/Android-AccountChooser

这篇关于的AccountManager:如何让用户选择使用一个对话框账户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆