是否可以使用 Android API 使用自定义表单创建 Google 帐户?

发布于 2024-12-12 20:51:56 字数 968 浏览 5 评论 0原文

我正在为新固件开发欢迎应用程序。 该应用程序将在恢复出厂设置后立即运行。 我想知道是否有一种方法可以创建一个谷歌帐户(如果新用户还没有)用于联系人和电话同步。 我有 SimpleSyncAdapter 示例,但我很难弄清楚如何将其与自定义活动表单一起使用,这将是教程/欢迎应用程序的一个步骤。在 google 示例中,AuthenticatorActivity 启动一个 AuthenticationService 来实例化 Authentication 类。

Authentication 类具有以下方法:

public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
    String authTokenType, String[] requiredFeatures, Bundle options) {

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

但我无法在我的 AccountActivity 中实例化扩展 AbstractAccountAuthenticator 的 Authentication 类。另外,我不确定这是否会对我有帮助。我不清楚这个方法的作用。

任何人都可以透露一些信息吗?

谢谢大家!

I'm working on a Welcome app for a new firmware.
This app will run right after a factory reset.
I would like to know if there's a way to create a google account (if the new user doesn't have one already) for contacts and callendar sync.
I've got the SimpleSyncAdapter sample and I'm having a hard time figure out how to use that with a custom activity form that will be one step of the tutorial/welcome app. In the google sample the AuthenticatorActivity starts an AuthenticationService that instantiates the Authentication class.

The Authentication class has the following method:

public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
    String authTokenType, String[] requiredFeatures, Bundle options) {

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

But I'm not able to instantiate the Authentication class that extends AbstractAccountAuthenticator in my AccountActivity. Also, I'm not sure if this will rly help me. It's not clear to me what this method does.

Can anyone shed some light?

Thank you all!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文