Java tutorial
//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); } }