Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

import android.content.Context;

import android.text.TextUtils;

public class Main {
    /**
     * Check if exist auth token for specified account
     * @param context context
     * @param account account to check
     * @param authTokenType auth token type
     * @return <code>true</code> if authToken for this account exist
     */
    public static boolean isAccountEnabled(Context context, Account account, String authTokenType) {
        if (account == null)
            return false;
        final AccountManager accountManager = AccountManager.get(context);
        String authToken = accountManager.peekAuthToken(account, authTokenType);
        if (TextUtils.isEmpty(authToken)) {
            return false;
        } else {
            return true;
        }
    }
}