moh.sukhni moh.sukhni - 24 days ago 4x
Android Question

how to open "Add a Google Account" activity using intent?

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("", "ah", null, new Bundle(), context, null, null);

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


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

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