Java Code Examples for android.content.SyncStatusObserver

The following are top voted examples for showing how to use android.content.SyncStatusObserver. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: android-wg-planer   File: SyncStatusManager.java   View source code 4 votes vote down vote up
public SyncStatusManager(Context context, String authority) {
    mContext = context;
    mAuthority = authority;
    syncObserver = new SyncStatusObserver() {
        @Override
        public void onStatusChanged(final int which) {
            AccountManager accountManager = AccountManager.get(mContext);
            if (accountManager != null) {
                Account[] accounts = accountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE);
                if (accounts.length > 0) {
                    Account account = accounts[0];


                    int state = -1;
                    if (which == ContentResolver.SYNC_OBSERVER_TYPE_PENDING) {
                        // 'Pending' state changed.
                        if (ContentResolver.isSyncPending(account, mAuthority)) {
                            // There is now a pending sync.
                            state = STATE_NOW_PENDING;
                        } else {
                            // There is no longer a pending sync.
                            state = STATE_NO_LONGER_PENDING;
                        }
                    } else if (which == ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE) {
                        // 'Active' state changed.
                        if (ContentResolver.isSyncActive(account, mAuthority)) {
                            // There is now an active sync.
                            state = STATE_NOW_SYNCING;
                        } else {
                            // There is no longer an active sync.
                            state = STATE_NO_LONGER_SYNCING;
                        }
                    }

                    Log.d(MainActivity.TAG, "Notifying sync status: " + state);
                    for (OnSyncStatusChangedListener listener : listeners) {
                        listener.onStatusChanged(state, mAuthority);
                    }
                }
            }
        }
    };
}
 
Example 2
Project: 365browser   File: SystemSyncContentResolverDelegate.java   View source code 4 votes vote down vote up
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
    return ContentResolver.addStatusChangeListener(mask, callback);
}
 
Example 3
Project: android-chromium   File: SystemSyncContentResolverDelegate.java   View source code 4 votes vote down vote up
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
    return ContentResolver.addStatusChangeListener(mask, callback);
}
 
Example 4
Project: cordova-android-chromium   File: SystemSyncContentResolverDelegate.java   View source code 4 votes vote down vote up
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
    return ContentResolver.addStatusChangeListener(mask, callback);
}
 
Example 5
Project: 365browser   File: SyncContentResolverDelegate.java   View source code votes vote down vote up
Object addStatusChangeListener(int mask, SyncStatusObserver callback); 
Example 6
Project: android-chromium   File: SyncContentResolverDelegate.java   View source code votes vote down vote up
Object addStatusChangeListener(int mask, SyncStatusObserver callback); 
Example 7
Project: cordova-android-chromium   File: SyncContentResolverDelegate.java   View source code votes vote down vote up
Object addStatusChangeListener(int mask, SyncStatusObserver callback);