本文整理汇总了Java中android.content.SyncStatusObserver类的典型用法代码示例。如果您正苦于以下问题:Java SyncStatusObserver类的具体用法?Java SyncStatusObserver怎么用?Java SyncStatusObserver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SyncStatusObserver类属于android.content包,在下文中一共展示了SyncStatusObserver类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SyncStatusManager
import android.content.SyncStatusObserver; //导入依赖的package包/类
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);
}
}
}
}
};
}
示例2: addStatusChangeListener
import android.content.SyncStatusObserver; //导入依赖的package包/类
@Override
public Object addStatusChangeListener(int mask, SyncStatusObserver callback) {
return ContentResolver.addStatusChangeListener(mask, callback);
}
示例3: addStatusChangeListener
import android.content.SyncStatusObserver; //导入依赖的package包/类
Object addStatusChangeListener(int mask, SyncStatusObserver callback);