Java 类android.content.SyncStatusObserver 实例源码
项目:android-wg-planer
文件:SyncStatusManager.java
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);
}
}
}
}
};
}
项目:365browser
文件:SystemSyncContentResolverDelegate.java
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
return ContentResolver.addStatusChangeListener(mask, callback);
}
项目:android-chromium
文件:SystemSyncContentResolverDelegate.java
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
return ContentResolver.addStatusChangeListener(mask, callback);
}
项目:cordova-android-chromium
文件:SystemSyncContentResolverDelegate.java
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
return ContentResolver.addStatusChangeListener(mask, callback);
}
项目:365browser
文件:SyncContentResolverDelegate.java
Object addStatusChangeListener(int mask, SyncStatusObserver callback);
项目:android-chromium
文件:SyncContentResolverDelegate.java
Object addStatusChangeListener(int mask, SyncStatusObserver callback);
项目:cordova-android-chromium
文件:SyncContentResolverDelegate.java
Object addStatusChangeListener(int mask, SyncStatusObserver callback);