Invalidate the authentication token for specified auth. - Android Account

Android examples for Account:Account Information

Description

Invalidate the authentication token for specified auth.

Demo Code


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

public class Main {
    /**//w  w w.  j a  va  2 s.c  om
     * Invalidate the authentication token for specified <code>auth</code>.
     *
     * @param context       A {@link Context} object
     * @param account       An {@link Account}
     * @param authTokenType The type of the token
     */
    public static void invalidateToken(Context context, Account account,
            String authTokenType) {
        AccountManager accountManager = AccountManager.get(context);
        accountManager.invalidateAuthToken(account.type,
                getAuthToken(context, account, authTokenType));
    }

    /**
     * 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