Android Account - 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 Account class.

This code example shows how to use the following methods:
        Robolectric.shadowOf(am).addAccount(a1);
        assertThat(am.getAccounts()).isNotNull();
        assertThat(am.getAccounts().length).isEqualTo(1);
        assertThat(am.getAccounts()[0]).isSameAs(a1);
 
        Account a2 = new Account("name_b", "type_b");
        Robolectric.shadowOf(am).addAccount(a2);
        assertThat(am.getAccounts()).isNotNull();
        assertThat(am.getAccounts().length).isEqualTo(2);
        assertThat(am.getAccounts()[1]).isSameAs(a2);
    } 
 
    @Test 
    public void testGetAccountsByType() { 
        AccountManager am = AccountManager.get(app);
        assertThat(am.getAccountsByType("name_a")).isNotNull();
        assertThat(am.getAccounts().length).isEqualTo(0);
 
        Account a1 = new Account("name_a", "type_a");
        Robolectric.shadowOf(am).addAccount(a1);
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:
    } 
 
    @LargeTest 
    public void testAuthorityPersistence() throws Exception { 
        final Account account1 = new Account("a@example.com", "example.type");
        final Account account2 = new Account("b@example.com", "example.type.2");
        final String authority1 = "testprovider1";
        final String authority2 = "testprovider2";
        final Bundle extras1 = new Bundle();
        extras1.putString("a", "1");
        final Bundle extras2 = new Bundle();
        extras2.putString("a", "2");
        extras2.putLong("b", 2);
        extras2.putInt("c", 1);
        extras2.putBoolean("d", true);
        extras2.putDouble("e", 1.2);
        extras2.putFloat("f", 4.5f);
        extras2.putParcelable("g", account1);
        final int period1 = 200;
        final int period2 = 1000;

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:
 
    /** 
     * Test sorting of users that match login 
     */ 
    public void testLoginMatch() { 
        GitHubAccount account = new GitHubAccount(new Account("m", "t"),
                AccountManager.get(getContext()));
        UserComparator comparator = new UserComparator(account);
 
        assertTrue(comparator.compare(new User().setLogin("m"),
                new User().setLogin("a")) < 0); 
        assertTrue(comparator.compare(new User().setLogin("a"),
                new User().setLogin("m")) > 0); 
        assertTrue(comparator.compare(new User().setLogin("m"),
                new User().setLogin("z")) < 0); 
        assertTrue(comparator.compare(new User().setLogin("z"),
                new User().setLogin("m")) > 0); 
        assertEquals(
                0, 
                comparator.compare(new User().setLogin("m"),
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: toString
        new Account("name", "");
    } 
 
    @Test 
    public void shouldHaveToString() throws Exception { 
        Account account = new Account("name", "type");
        assertThat(account.toString()).isEqualTo("Account {name=name, type=type}");
    } 
 
    @Test 
    public void shouldProvideEqualAndHashCode() throws Exception { 
        assertThat(new Account("a", "b")).isEqualTo(new Account("a", "b"));
        assertThat(new Account("a", "b")).isNotEqualTo(new Account("c", "b"));
        assertThat(new Account("a", "b").hashCode()).isEqualTo(new Account("a", "b").hashCode());
        assertThat(new Account("a", "b").hashCode()).isNotEqualTo(new Account("c", "b").hashCode());
    } 
} 
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:
@RunWith(TestRunners.WithDefaults.class) 
public class PeriodicSyncTest { 
 
    @Test 
    public void shouldHaveConstructor() throws Exception { 
        Account a = new Account("a", "b"); 
        PeriodicSync sync = new PeriodicSync(a, "auth", 
                new Bundle(), 120l); 
 
        assertThat(sync.account).isSameAs(a); 
        assertThat(sync.authority).isEqualTo("auth"); 
        assertThat(sync.period).isEqualTo(120l); 
        assertNotNull(sync.extras); 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Account Questions & Answers:

See Code Examples for Android Account Methods: