ensure User Is Logged In using AccountManager - Android android.accounts

Android examples for android.accounts:AccountManager

Description

ensure User Is Logged In using AccountManager

Demo Code


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

Related Tutorials