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

This code example shows how to use the following methods:
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); 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
        final int period1 = 200;
        final int period2 = 1000;
 
        PeriodicSync sync1 = new PeriodicSync(account1, authority1, extras1, period1);
        PeriodicSync sync2 = new PeriodicSync(account1, authority1, extras2, period1);
        PeriodicSync sync3 = new PeriodicSync(account1, authority2, extras1, period1);
        PeriodicSync sync4 = new PeriodicSync(account1, authority2, extras2, period2);
        PeriodicSync sync5 = new PeriodicSync(account2, authority1, extras1, period1);
 
        MockContentResolver mockResolver = new MockContentResolver();
 
        SyncStorageEngine engine = SyncStorageEngine.newTestInstance(
                new TestContext(mockResolver, getContext()));
 
        removePeriodicSyncs(engine, account1, 0, authority1);
        removePeriodicSyncs(engine, account2, 0, authority1);
        removePeriodicSyncs(engine, account1, 0, authority2);
        removePeriodicSyncs(engine, account2, 0, authority2);
 
        engine.setMasterSyncAutomatically(false, 0);
6
CodeRank
This code example shows how to use the following methods:
        final int period1 = 200;
        final int period2 = 1000;
 
        PeriodicSync sync1 = new PeriodicSync(account1, authority, extras1, period1);
        PeriodicSync sync2 = new PeriodicSync(account1, authority, extras2, period1);
        PeriodicSync sync3 = new PeriodicSync(account1, authority, extras2, period2);
        PeriodicSync sync4 = new PeriodicSync(account2, authority, extras2, period2);
 
        MockContentResolver mockResolver = new MockContentResolver();
 
        SyncStorageEngine engine = SyncStorageEngine.newTestInstance(
                new TestContext(mockResolver, getContext()));
 
        removePeriodicSyncs(engine, account1, 0, authority);
        removePeriodicSyncs(engine, account2, 0, authority);
        removePeriodicSyncs(engine, account1, 1, authority);
 
        // this should add two distinct periodic syncs for account1 and one for account2 
        engine.addPeriodicSync(sync1.account, 0, sync1.authority, sync1.extras, sync1.period);
        engine.addPeriodicSync(sync2.account, 0, sync2.authority, sync2.extras, sync2.period);
4
CodeRank
This code example shows how to use the following methods:
        final int period2 = 1000;
 
        PeriodicSync sync1 = new PeriodicSync(account1, authority, extras1, period1);
        PeriodicSync sync2 = new PeriodicSync(account1, authority, extras2, period1);
        PeriodicSync sync3 = new PeriodicSync(account1, authority, extras2, period2);
        PeriodicSync sync4 = new PeriodicSync(account2, authority, extras2, period2);
 
        MockContentResolver mockResolver = new MockContentResolver();
 
        SyncStorageEngine engine = SyncStorageEngine.newTestInstance(
                new TestContext(mockResolver, getContext()));
 
        removePeriodicSyncs(engine, account1, 0, authority);
        removePeriodicSyncs(engine, account2, 0, authority);
        removePeriodicSyncs(engine, account1, 1, authority);
 
        // this should add two distinct periodic syncs for account1 and one for account2 
        engine.addPeriodicSync(sync1.account, 0, sync1.authority, sync1.extras, sync1.period);
        engine.addPeriodicSync(sync2.account, 0, sync2.authority, sync2.extras, sync2.period);
        engine.addPeriodicSync(sync3.account, 0, sync3.authority, sync3.extras, sync3.period);
3
CodeRank
See Code Examples for Android PeriodicSync Methods: