Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.accounts.Account;
import android.accounts.AccountManager;

public class Main {
    /**
     * Sets password of account, creates a new account if necessary.
     */
    private static Account findOrCreateAccount(AccountManager accountManager, String username, String refreshToken,
            String accountType) {

        for (Account account : accountManager.getAccountsByType(accountType)) {
            if (account.name.equals(username)) {
                accountManager.setPassword(account, refreshToken);
                return account;
            }
        }

        Account account = new Account(username, accountType);
        accountManager.addAccountExplicitly(account, refreshToken, null);
        return account;
    }
}