当前位置: 首页>>代码示例>>Java>>正文


Java AccountManager.getPassword方法代码示例

本文整理汇总了Java中android.accounts.AccountManager.getPassword方法的典型用法代码示例。如果您正苦于以下问题:Java AccountManager.getPassword方法的具体用法?Java AccountManager.getPassword怎么用?Java AccountManager.getPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.accounts.AccountManager的用法示例。


在下文中一共展示了AccountManager.getPassword方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSyncAccount

import android.accounts.AccountManager; //导入方法依赖的package包/类
static Account getSyncAccount(Context context, int syncInterval, int syncFlexTime) {
    // 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.rnsb_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, syncInterval, syncFlexTime);
    }
    return newAccount;
}
 
开发者ID:ferrannp,项目名称:react-native-sync-adapter,代码行数:30,代码来源:SyncAdapter.java

示例2: getSyncAccount

import android.accounts.AccountManager; //导入方法依赖的package包/类
/**
 * 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.
 */
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;
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:39,代码来源:SunshineSyncAdapter.java

示例3: getAuthToken

import android.accounts.AccountManager; //导入方法依赖的package包/类
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
                           Bundle options) throws NetworkErrorException {
    final AccountManager am = AccountManager.get(context);
    String authToken = am.peekAuthToken(account, authTokenType);

    // get new token if there is no one
    if (TextUtils.isEmpty(authToken)) {
        String password = am.getPassword(account);
        if (password != null) {
            try {
                password = Crypto.armorDecrypt(password, context);
                authToken = serverHandler.userSignIn(account.name, password);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // there is new token, return it
    if (!TextUtils.isEmpty(authToken)) {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
        return result;
    }

    // no token and no password, show login screen
    final Intent intent = new Intent(context, loginActivity);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    intent.putExtra(GlobalConstant.ACCOUNT_TYPE, account.type);
    intent.putExtra(GlobalConstant.ACCOUNT_NAME, account.name);
    intent.putExtra(IS_ADDING_NEW_ACCOUNT, false);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:39,代码来源:ICalAuthenticator.java

示例4: getSyncAccount

import android.accounts.AccountManager; //导入方法依赖的package包/类
/**
 * 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.
 */
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 desc 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;
        }
        onAccountCreated(newAccount, context);
    }
    return newAccount;
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:29,代码来源:TvGuideSyncAdapter.java

示例5: getSyncAccount

import android.accounts.AccountManager; //导入方法依赖的package包/类
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),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;
}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:30,代码来源:SyncAdapter.java


注:本文中的android.accounts.AccountManager.getPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。