Android AccountManager - top ranked examples from Open Source projects

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

This code example shows how to use the following methods: get
        super(context, executor);
    } 
 
    @Override 
    public final ResultT call() throws Exception { 
        final AccountManager manager = AccountManager.get(activity);
        final Account account = AccountUtils.getAccount(manager, activity);
 
        accountScope.enterWith(account, manager);
        try { 
            contextScope.enter(getContext());
            try { 
                return run(account);
            } catch (IOException e) {
                // Retry task if authentication failure occurs and account is 
                // successfully updated 
                if (AccountUtils.isUnauthorized(e)
                        && AccountUtils.updateAccount(account, activity))
                    return run(account);
                else 

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: get
     */ 
    protected abstract D getAccountFailureData(); 
 
    @Override 
    public final D loadInBackground() { 
        final AccountManager manager = AccountManager.get(activity);
        final Account account;
        try { 
            account = AccountUtils.getAccount(manager, activity);
        } catch (IOException e) {
            return getAccountFailureData(); 
        } catch (AccountsException e) {
            return getAccountFailureData(); 
        } 
 
        accountScope.enterWith(account, manager);
        try { 
            contextScope.enter(getContext());
            try { 
                return load(account);
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: get
    public void testGet() { 
        AccountManager appAM = AccountManager.get(app);
        assertThat(appAM).isNotNull();
        assertSame(AccountManager.get(app), appAM);
 
        Activity a = new Activity();
        assertThat(AccountManager.get(a)).isNotNull();
        assertThat(AccountManager.get(a)).isNotSameAs(appAM);
    } 
 
    @Test 
    public void testGetAccounts() { 
        AccountManager am = AccountManager.get(app);
        assertThat(am.getAccounts()).isNotNull();
        assertThat(am.getAccounts().length).isEqualTo(0);
 
        Account a1 = new Account("name_a", "type_a");
        Robolectric.shadowOf(am).addAccount(a1);
        assertThat(am.getAccounts()).isNotNull();
        assertThat(am.getAccounts().length).isEqualTo(1);
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getPassword
     * Get password 
     * 
     * @return password 
     */ 
    public String getPassword() {
        return manager.getPassword(account);
    } 
 
    /** 
     * Get auth token 
     * 
     * @return token 
     */ 
    public String getAuthToken() {
        @SuppressWarnings("deprecation") 
        AccountManagerFuture<Bundle> future = manager.getAuthToken(account,
                ACCOUNT_TYPE, false, null, null); 
 
        try { 
            Bundle result = future.getResult();
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addAccount, putParcelable
        outState.putBoolean(KEY_ADD_CALLED, mAddAccountCalled);
        if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "saved");
    } 
 
    private void addAccount(String accountType) {
        Bundle addAccountOptions = new Bundle();
        mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
        addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
        AccountManager.get(this).addAccount(
                accountType,
                null, /* authTokenType */ 
                null, /* requiredFeatures */ 
                addAccountOptions,
                this,
                mCallback,
                null /* handler */); 
        mAddAccountCalled  = true;
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android AccountManager Questions & Answers:

See Code Examples for Android AccountManager Methods: