find Google Account - Android Account

Android examples for Account:Account Information

Description

find Google Account

Demo Code


//package com.java2s;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.text.TextUtils;

public class Main {
    private static final String GOOGLE_TYPE = "com.google";

    public static Account findGoogleAccount(Context context, String name) {
        AccountManager am = AccountManager.get(context);
        for (final Account a : am.getAccountsByType(GOOGLE_TYPE)) {
            if (TextUtils.equals(a.name, name))
                return a;
        }/*  w  w  w .ja v  a2s . c om*/
        return null;
    }
}

Related Tutorials