如何打开“添加Google帐户”活动使用意图? [英] how to open "Add a Google Account" activity using intent?

查看:218
本文介绍了如何打开“添加Google帐户”活动使用意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是如何使用意图打开添加Google帐户活动而不使用需要以下权限的AccountManager:

My question is how to open "Add a Google Account" activity using intent without using AccountManager which requires the following permission:

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

我的意思是找到解决以下方案的方法:

I mean find a way to go around the following solution:

AccountManager accountMgr = AccountManager.get(context);
accountMgr.addAccount("com.google", "ah", null, new Bundle(), context, null, null);

我会为那里寻找解决此问题的人提供解决方案。

I'll provide the solution for anyone out there searching for the solve this issue.

推荐答案

通过提供 EXTRA_ACCOUNT_TYPES 。并将值设置为com.google以提醒活动:

the answer for the above question by providing EXTRA_ACCOUNT_TYPES in the intent extra data. and set the value to "com.google" in order to alert the activity:

public static void startAddGoogleAccountIntent(Context context)
{
    Intent addAccountIntent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT)
    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    addAccountIntent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[] {"com.google"});
    context.startActivity(addAccountIntent); 
}

这篇关于如何打开“添加Google帐户”活动使用意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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