get Account Name - Android Account

Android examples for Account:Account Name

Description

get Account Name

Demo Code


//package com.java2s;

import android.accounts.Account;
import android.accounts.AccountManager;

import android.content.Context;

public class Main {
    public static final String LETV_ACCOUNT_TYPE = "com.letv";

    public static String getAccountName(Context context) {
        AccountManager am = AccountManager.get(context);
        final Account[] accountList = am.getAccountsByType(LETV_ACCOUNT_TYPE);
        String username = null;/*from www  . j av a 2s.co m*/
        if (accountList != null && accountList.length > 0) {
            username = accountList[0].name;
        }
        return username;
    }
}

Related Tutorials