AccountManager addAccountExplicitly - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AccountManager addAccountExplicitly method.

This code example shows how to use the following methods:addAccountExplicitly
            // There are two cases here: 
            // 1) We are called with a username/password; this comes from the traditional email 
            //    app UI; we simply create the account and return the proper bundle 
            if (options != null && options.containsKey(OPTIONS_PASSWORD)
                    && options.containsKey(OPTIONS_USERNAME)) {
                final Account account = new Account(options.getString(OPTIONS_USERNAME),
                        TEST_ACCOUNT_TYPE);
                AccountManager.get(EasTestAuthenticatorService.this).addAccountExplicitly(
                            account, options.getString(OPTIONS_PASSWORD), null);
 
                Bundle b = new Bundle();
                b.putString(AccountManager.KEY_ACCOUNT_NAME, TEST_ACCOUNT_TYPE);
                return b;
            // 2) The other case is that we're creating a new account from an Account manager 
            //    activity.  In this case, we add an intent that will be used to gather the 
            //    account information... 
            } else { 
                Bundle b = new Bundle();
                Intent intent =
                    AccountSetupBasics.actionSetupExchangeIntent(EasTestAuthenticatorService.this);
7
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
            // There are two cases here: 
            // 1) We are called with a username/password; this comes from the traditional email 
            //    app UI; we simply create the account and return the proper bundle 
            if (options != null && options.containsKey(OPTIONS_PASSWORD)
                    && options.containsKey(OPTIONS_USERNAME)) {
                final Account account = new Account(options.getString(OPTIONS_USERNAME), ANDROID_ACCOUNT_TYPE);
                AccountManager.get(AuthenticatorService.this).addAccountExplicitly(
                            account, options.getString(OPTIONS_PASSWORD), null);
 
                /* TODO: 
                // Set up email syncing 
                boolean syncEmail = false; 
                if (options.containsKey(OPTIONS_EMAIL_SYNC_ENABLED) && 
                        options.getBoolean(OPTIONS_EMAIL_SYNC_ENABLED)) { 
                    syncEmail = true; 
                } 
                 
                ContentResolver.setIsSyncable(account, EmailContent.AUTHORITY, 1); 
                ContentResolver.setSyncAutomatically(account, EmailContent.AUTHORITY, syncEmail); 
                ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 0); 
5
CodeRank
This code example shows how to use the following methods:addAccountExplicitly, setAuthToken
            String authtoken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN);
            String authtokenType = mAuthTokenType;
 
            // Creating the account on the device and setting the auth token we got 
            // (Not setting the auth token will cause another call to the server to authenticate the user) 
            mAccountManager.addAccountExplicitly(account, accountPassword, null);
            mAccountManager.setAuthToken(account, authtokenType, authtoken);
        } else { 
            Log.d(TAG, TAG + "> finishLogin > setPassword");
            mAccountManager.setPassword(account, accountPassword);
        } 
        setAccountAuthenticatorResult(intent.getExtras());
        setResult(RESULT_OK, intent);
        finish();
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
            // There are two cases here: 
            // 1) We are called with a username/password; this comes from the traditional email 
            //    app UI; we simply create the account and return the proper bundle 
            if (options != null && options.containsKey(OPTIONS_PASSWORD)
                    && options.containsKey(OPTIONS_USERNAME)) {
                final Account account = new Account(options.getString(OPTIONS_USERNAME),
                        TEST_ACCOUNT_TYPE);
                AccountManager.get(EasTestAuthenticatorService.this).addAccountExplicitly(
                            account, options.getString(OPTIONS_PASSWORD), null);
 
                Bundle b = new Bundle();
                b.putString(AccountManager.KEY_ACCOUNT_NAME, TEST_ACCOUNT_TYPE);
                return b;
            // 2) The other case is that we're creating a new account from an Account manager 
            //    activity.  In this case, we add an intent that will be used to gather the 
            //    account information... 
            } else { 
                Bundle b = new Bundle();
                Intent intent =
                    AccountSetupBasics.actionSetupExchangeIntent(EasTestAuthenticatorService.this);
5
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
 
	@Override 
	protected void tearDown() throws Exception{ 
 
		// When we tear down, we want to replace the username and pass 
		am.addAccountExplicitly(oldAccount, oldPassword, null);
 
		try { 
			solo.finalize();
		} catch (Throwable e) { 
			e.printStackTrace();
		} 
		getActivity().finish();  
		super.tearDown(); 
	} 
 
	public void testInitialLogin() { 
		if(SharedPreferencesHelper.PASSWORD == null || (SharedPreferencesHelper.USERNAME == null && oldAccount.name == null))
			throw new RuntimeException("The username and password constants must be set in order to log in");
 
5
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
		fail("Test the back button to make sure it is not possible to get to the app after logout");
	} 
 
	private void resetCredentials() { 
	    if(account != null)
	        am.addAccountExplicitly(account, password, null);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
        return mAccountManager.getAccounts();
    } 
 
    @Override 
    public boolean addAccountExplicitly(Account account, String password, Bundle userdata) {
        return mAccountManager.addAccountExplicitly(account, password, userdata);
    } 
 
    @Override 
    public AccountManagerFuture<Boolean> removeAccount(Account account,
            AccountManagerCallback<Boolean> callback, Handler handler) {
        return mAccountManager.removeAccount(account, callback, handler);
    } 
 
    @Override 
    public String getPassword(Account account) {
        return mAccountManager.getPassword(account);
    } 
 
    @Override 
4
CodeRank
This code example shows how to use the following methods:addAccountExplicitly, getAccountsByType
		return null; 
	} 
	void internalAddAccount() { 
    	//TODO: this does DB-access, so it needs to actually happen in a background thread. 
		final Account account = new Account(mAccountName, mAccountType);
		Account[] acs = mAccountManager.getAccountsByType(mAccountType);
		if(acs.length == 0) {
			Log.v(TAG, "actually adding account for " + mAccountName + " with type " + mAccountType);
			SyncAdapter.setSyncMarker(mContext, 0);
			mAccountManager.addAccountExplicitly(account, "", null);
 
			ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
			ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
			 
			//also force it to sync once 
			ContentResolver.requestSync(account, ContactsContract.AUTHORITY, new Bundle());
		} 
	} 
 
	@Override 
4
CodeRank
This code example shows how to use the following methods:addAccountExplicitly
This code example shows how to use the following methods:addAccountExplicitly
     *   </intent-filter>  
     */ 
    public void createAccount(String acctName, String displayPage) {
    	if( acctName != null && acctName.equals("") == false ) {
    		mAcctName = acctName;
    		AccountManager.get(this).addAccountExplicitly(
    			new Account(mAcctName, mAcctType), "dummyPassword", null);
    	} 
    	 
    	loadURL(displayPage);
    } 
} 
4
CodeRank

Related AccountManager addAccountExplicitly Questions & Answers:

addAccountExplicitly Method Overview
Adds an account directly to the AccountManager.
See Code Examples for other Android AccountManager Methods: