Retrieve the authentication token for given auth. - Android Account

Android examples for Account:Account Information

Description

Retrieve the authentication token for given auth.

Demo Code


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

public class Main {
    /**/* www  .ja  va 2 s . c o m*/
     * Retrieve the authentication token for given <code>auth</code>.
     *
     * @param context       A {@link Context} object
     * @param account       An {@link Account}
     * @param authTokenType The type of the token
     * @return Authentication token for given <code>auth</code>, <code>null</code>
     * if there is no token for some reason
     */
    public static String getAuthToken(Context context, Account account,
            String authTokenType) {
        AccountManager accountManager = AccountManager.get(context);
        return accountManager.peekAuthToken(account, authTokenType);
    }
}

Related Tutorials