Example usage for android.content ContentResolver isSyncPending

List of usage examples for android.content ContentResolver isSyncPending

Introduction

In this page you can find the example usage for android.content ContentResolver isSyncPending.

Prototype

public static boolean isSyncPending(Account account, String authority) 

Source Link

Document

Return true if the pending status is true of any matching authorities.

Usage

From source file:com.manning.androidhacks.hack023.MainActivity.java

public void refresh(View v) {
    Bundle extras = new Bundle();
    extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);

    Account account = ((HackApplication) getApplication()).getCurrentAccount();

    if (ContentResolver.isSyncPending(account, TodoContentProvider.AUTHORITY)) {
        ContentResolver.cancelSync(account, TodoContentProvider.AUTHORITY);
    }/*  ww  w .j  a  va  2 s.  com*/

    ContentResolver.requestSync(account, TodoContentProvider.AUTHORITY, extras);
}

From source file:dev.drsoran.moloko.sync.util.SyncUtils.java

public final static boolean isSyncing(Context context) {
    final Account account = AccountUtils.getRtmAccount(context);

    return account != null && !ContentResolver.isSyncPending(account, Rtm.AUTHORITY)
            && ContentResolver.isSyncActive(account, Rtm.AUTHORITY);
}

From source file:org.kontalk.sync.SyncAdapter.java

public static boolean isPending(Context context) {
    Account acc = Authenticator.getDefaultAccount(context);
    return ContentResolver.isSyncPending(acc, ContactsContract.AUTHORITY);
}

From source file:edu.mit.mobile.android.locast.ver2.browser.BrowserHome.java

@Override
protected void onResume() {
    super.onResume();
    mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new SyncStatusObserver() {

        @Override/* w  w w  .  j ava2 s. co  m*/
        public void onStatusChanged(int which) {
            Account a = Authenticator.getFirstAccount(BrowserHome.this);
            if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
                    && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
                Log.d(TAG, "Sync finished, should refresh naw!!");
                mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);

            } else {
                Log.d(TAG, "Sync Active or Pending!!");
                mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
            }
        }
    });
    //check if synch is in progress 
    Account a = Authenticator.getFirstAccount(BrowserHome.this);
    if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
            && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
        Log.d(TAG, "Sync finished, should refresh naw!!");
        mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);
    } else {
        Log.d(TAG, "Sync Active or Pending!!");
        mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
    }

    if (shouldRefresh) {
        refresh(false);
    }

}

From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryList.java

@Override
protected void onResume() {
    super.onResume();

    mSyncWhenLoaded = true;/*w w  w .  java 2  s.  c om*/
    mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new SyncStatusObserver() {

        @Override
        public void onStatusChanged(int which) {
            Account a = Authenticator.getFirstAccount(ItineraryList.this);
            if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
                    && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
                Log.d(TAG, "Sync finished, should refresh naw!!");
                mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);

            } else {
                Log.d(TAG, "Sync Active or Pending!!");
                mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
            }
        }
    });
    //check if synch is in progress 
    Account a = Authenticator.getFirstAccount(ItineraryList.this);
    if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
            && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
        Log.d(TAG, "Sync finished, should refresh naw!!");
        mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);
    } else {
        Log.d(TAG, "Sync Active or Pending!!");
        mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
    }
}

From source file:org.ohmage.fragments.HomeFragment.java

public void checkSyncStatus() {
    Account[] accounts = am.getAccountsByType(AuthUtil.ACCOUNT_TYPE);
    if (accounts.length == 0) {
        return;//  w w  w.  j  av a  2 s  .  c  o m
    }

    mHandler.removeCallbacks(mRefreshCompleteRunnable);
    if (ContentResolver.isSyncActive(accounts[0], OhmageContract.CONTENT_AUTHORITY)
            || ContentResolver.isSyncPending(accounts[0], OhmageContract.CONTENT_AUTHORITY)) {
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (getListAdapter() == null || getListAdapter().isEmpty()) {
                    mPullToRefreshLayout.setRefreshing(true);
                    setEmptyText("Please wait for Surveys to Synchronize...");
                }
            }
        });
    } else {
        mHandler.postDelayed(mRefreshCompleteRunnable, 500);
    }
}

From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryDetail.java

@Override
protected void onResume() {
    mFirstLoadSync = true;/*from w  w  w  .j  a v a2 s .com*/
    super.onResume();
    mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new SyncStatusObserver() {

        @Override
        public void onStatusChanged(int which) {
            final Account a = Authenticator.getFirstAccount(ItineraryDetail.this);
            if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
                    && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
                Log.d(TAG, "Sync finished, should refresh naw!!");
                mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);

            } else {
                Log.d(TAG, "Sync Active or Pending!!");
                mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
            }
        }
    });
    //check if synch is in progress
    final Account a = Authenticator.getFirstAccount(ItineraryDetail.this);
    if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
            && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
        Log.d(TAG, "Sync finished, should refresh naw!!");
        mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);
    } else {
        Log.d(TAG, "Sync Active or Pending!!");
        mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
    }
}

From source file:edu.mit.mobile.android.locast.ver2.casts.LocatableListWithMap.java

@Override
protected void onResume() {
    super.onResume();
    mMyLocationOverlay.enableMyLocation();
    mExpeditedSync = true;//w  w w. jav  a 2  s. c  om
    mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new SyncStatusObserver() {

        @Override
        public void onStatusChanged(int which) {
            Account a = Authenticator.getFirstAccount(LocatableListWithMap.this);
            if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
                    && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
                Log.d(TAG, "Sync finished, should refresh naw!!");
                mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);

            } else {
                Log.d(TAG, "Sync Active or Pending!!");
                mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
            }
        }
    });
    //check if synch is in progress 
    Account a = Authenticator.getFirstAccount(LocatableListWithMap.this);
    if (!ContentResolver.isSyncActive(a, MediaProvider.AUTHORITY)
            && !ContentResolver.isSyncPending(a, MediaProvider.AUTHORITY)) {
        Log.d(TAG, "Sync finished, should refresh naw!!");
        mHandler.sendEmptyMessage(MSG_SET_NOT_REFRESHING);
    } else {
        Log.d(TAG, "Sync Active or Pending!!");
        mHandler.sendEmptyMessage(MSG_SET_REFRESHING);
    }
}

From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java

public void actionRefresh() {
    // only if neither pending nor active
    if (!ContentResolver.isSyncActive(((MainActivity) getActivity()).mDefaultAccount,
            getString(Account.CONTENT_AUTHORITY))
            && !ContentResolver.isSyncPending(((MainActivity) getActivity()).mDefaultAccount,
                    getString(Account.CONTENT_AUTHORITY))) {
        Bundle settingsBundle = new Bundle();
        settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); // this is a manual sync
        settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); // start immediately
        ContentResolver.requestSync(Authenticator.getDefaultAccount(getActivity()),
                getString(Account.CONTENT_AUTHORITY), settingsBundle);
    }/*from w ww .  ja  va  2s.  c om*/
}