Android examples for android.accounts:AccountManager
ensure User Is Logged Out using AccountManager
//package com.java2s; import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerFuture; import android.content.Context; public class Main { public static void ensureUserIsLoggedOut(Context context, String accountType) { AccountManager manager = (AccountManager) context .getSystemService(Context.ACCOUNT_SERVICE); Account[] accounts = manager.getAccountsByType(accountType); for (Account account : accounts) { AccountManagerFuture<Boolean> removeAccount = manager .removeAccount(account, null, null); waitForAccountToBeRemoved(removeAccount); }//from w w w . j a v a 2 s. c o m } private static void waitForAccountToBeRemoved( AccountManagerFuture<Boolean> removeAccount) { while (!removeAccount.isDone()) { } } }