Android examples for android.accounts:AccountManager
ensure User Is Logged In using AccountManager
//package com.java2s; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; public class Main { public static void ensureUserIsLoggedIn(Context context, String accountType) { AccountManager manager = (AccountManager) context .getSystemService(Context.ACCOUNT_SERVICE); Account account = new Account("username", accountType); String password = "testpassword"; manager.addAccountExplicitly(account, password, null); }//w w w . j a va 2 s . com }