Example usage for android.accounts AccountManager getPassword

List of usage examples for android.accounts AccountManager getPassword

Introduction

In this page you can find the example usage for android.accounts AccountManager getPassword.

Prototype

public String getPassword(final Account account) 

Source Link

Document

Gets the saved password associated with the account.

Usage

From source file:Main.java

public static String getPassword(AccountManager paramAccountManager, Account paramAccount) {
    return paramAccountManager.getPassword(paramAccount);
}

From source file:Main.java

public static String getPassword(Context context, Account account) {
    AccountManager accountManager = AccountManager.get(context);
    return accountManager.getPassword(account);
}

From source file:Main.java

/**
 * Get password of specified account//w w  w .j a  v a2  s  .c  o  m
 * @param context context
 * @param account account
 * @return account password
 */
public static String getAccountPassword(Context context, Account account) {
    if (account == null)
        return null;
    AccountManager accountManager = AccountManager.get(context);
    return accountManager.getPassword(account);
}

From source file:com.example.igorklimov.popularmoviesdemo.sync.SyncAdapter.java

/**
 * Create a new dummy account for the sync adapter
 *
 * @param context The application context
 *//*w  ww.j a  v a2s.c o  m*/
public static Account getSyncAccount(Context context) {
    Account newAccount = new Account(context.getString(R.string.app_name),
            context.getString(R.string.acc_sync_type));
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    if (accountManager.getPassword(newAccount) == null) {
        if (!accountManager.addAccountExplicitly(newAccount, "", null))
            return null;

        onAccountCreated(newAccount, context);
    }

    return newAccount;
}

From source file:inforuh.eventfinder.sync.SyncAdapter.java

public static Account getAccount(Context context) {
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    Account account = new Account(context.getString(R.string.app_name),
            context.getString(R.string.account_type));

    if (accountManager.getPassword(account) == null) {
        accountManager.addAccountExplicitly(account, "", null);
        onAccountCreated(account, context);
    }/*from  w w  w.j av  a 2 s .c om*/
    return account;
}

From source file:p1.nd.khan.jubair.mohammadd.popularmovies.sync.MovieSyncAdapter.java

/**
 * Helper method to get the fake account to be used with SyncAdapter, or make a new one
 * if the fake account doesn't exist yet.  If we make a new account, we call the
 * onAccountCreated method so we can initialize things.
 *
 * @param context  The context used to access the account service
 * @return a fake account.//w  w w . j  a  v a  2s .  c om
 */
public static Account getSyncAccount(Context context) {
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
    Account newAccount = new Account(context.getString(R.string.app_name),
            context.getString(R.string.sync_account_type));
    if (null == accountManager.getPassword(newAccount)) {
        if (!accountManager.addAccountExplicitly(newAccount, "", null)) {
            return null;
        }
        onAccountCreated(newAccount, context);
    }
    return newAccount;
}

From source file:com.beesham.popularmovies.sync.MoviesSyncAdapter.java

private static Account getSyncAccount(Context context) {
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    Account newAccount = new Account(context.getString(R.string.app_name),
            context.getString(R.string.sync_account_type));

    if (accountManager.getPassword(newAccount) == null) {
        if (!accountManager.addAccountExplicitly(newAccount, "", null)) {
            return null;
        }/*from w ww  .  ja  va 2  s  . c o m*/
        onAccountCreated(newAccount, context);
    }
    return newAccount;
}

From source file:tech.salroid.filmy.syncs.FilmySyncAdapter.java

/**
 * Helper method to get the fake account to be used with SyncAdapter, or make a new one
 * if the fake account doesn't exist yet.  If we make a new account, we call the
 * onAccountCreated method so we can initialize things.
 *
 * @param context The context used to access the account service
 * @return a fake account./*from   w w w  . ja  va 2s  .co  m*/
 */
public static Account getSyncAccount(Context context) {
    // Get an instance of the Android account manager
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    // Create the account type and default account
    Account newAccount = new Account(context.getString(R.string.app_name),
            context.getString(R.string.sync_account_type));

    // If the password doesn't exist, the account doesn't exist
    if (null == accountManager.getPassword(newAccount)) {

        /*
         * Add the account and account type, no password or user data
         * If successful, return the Account object, otherwise report an error.
         */
        if (!accountManager.addAccountExplicitly(newAccount, "", null)) {
            return null;
        }
        /*
         * If you don't set android:syncable="true" in
         * in your <provider> element in the manifest,
         * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1)
         * here.
         */

        onAccountCreated(newAccount, context);

    }

    return newAccount;
}

From source file:com.hemou.android.account.AccountUtils.java

private static Account[] getPasswordAccessibleAccounts(final AccountManager manager, final Account[] candidates)
        throws AuthenticatorConflictException {
    final List<Account> accessible = new ArrayList<Account>(candidates.length);
    boolean exceptionThrown = false;
    for (Account account : candidates)
        try {/*from w w w .  j a va 2 s  . c o m*/
            manager.getPassword(account);
            accessible.add(account);
        } catch (SecurityException ignored) {
            exceptionThrown = true;
        }
    if (accessible.isEmpty() && exceptionThrown)
        throw new AuthenticatorConflictException();
    return accessible.toArray(new Account[accessible.size()]);
}

From source file:com.creationgroundmedia.popularmovies.sync.MovieSyncAdapter.java

public static Account getSyncAccount(Context context) {
    // Get an instance of the Android account manager
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    // Create the account type and default account
    Account newAccount = new Account(context.getString(R.string.app_name),
            context.getString(R.string.sync_account_type));

    // If the password doesn't exist, the account doesn't exist
    if (null == accountManager.getPassword(newAccount)) {

        /*/*from  www  .  j a  v a  2 s. com*/
         * Add the account and account type, no password or user data
         * If successful, return the Account object, otherwise report an error.
         */
        if (!accountManager.addAccountExplicitly(newAccount, "", null)) {
            return null;
        }
        /*
         * If you don't set android:syncable="true" in
         * in your <provider> element in the manifest,
         * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1)
         * here.
         */
        onAccountCreated(newAccount, context);
    }
    return newAccount;
}