当前位置: 首页>>代码示例>>Java>>正文


Java SyncRequest类代码示例

本文整理汇总了Java中android.content.SyncRequest的典型用法代码示例。如果您正苦于以下问题:Java SyncRequest类的具体用法?Java SyncRequest怎么用?Java SyncRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyncRequest类属于android.content包,在下文中一共展示了SyncRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Based on https://gist.github.com/udacityandroid/7230489fb8cb3f46afee
 */
private static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context, syncInterval, flexTime);
    String authority = context.getString(R.string.rnsb_content_authority);
    
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // We can enable inexact timers in our periodic sync (better for batter life)
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:ferrannp,项目名称:react-native-sync-adapter,代码行数:20,代码来源:SyncAdapter.java

示例2: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:19,代码来源:SunshineSyncAdapter.java

示例3: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.contentauthority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:amrendra18,项目名称:udacity-p3,代码行数:19,代码来源:FootballSyncAdapter.java

示例4: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.sync_provider_authority);
    if (syncInterval == -1) {
        ContentResolver.setSyncAutomatically(account, context.getString(R.string.sync_provider_authority), false);
    } else {
        ContentResolver.setSyncAutomatically(account, context.getString(R.string.sync_provider_authority), true);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // we can enable inexact timers in our periodic sync
            SyncRequest request = new SyncRequest.Builder().
                    syncPeriodic(syncInterval, flexTime).
                    setSyncAdapter(account, authority).
                    setExtras(new Bundle()).build();
            ContentResolver.requestSync(request);
        } else {
            ContentResolver.addPeriodicSync(account,
                    authority, new Bundle(), syncInterval);
        }
    }
}
 
开发者ID:dmytroKarataiev,项目名称:EarthquakeSurvival,代码行数:25,代码来源:SyncAdapter.java

示例5: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
private static void configurePeriodicSync(Context context, int syncInterval, int syncFlextime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        try {
            SyncRequest request = new SyncRequest.Builder().
                    syncPeriodic(syncInterval, syncFlextime).
                    setSyncAdapter(account, authority).build();
            ContentResolver.requestSync(request);
        } catch (Exception e) {
        }
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:davidsan,项目名称:DBUFR,代码行数:18,代码来源:DbufrSyncAdapter.java

示例6: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {

    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:salRoid,项目名称:Filmy,代码行数:20,代码来源:FilmySyncAdapter.java

示例7: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder()
                .syncPeriodic(syncInterval, flexTime)
                .setSyncAdapter(account, authority)
                .setExtras(new Bundle())
                .build();
        ContentResolver.requestSync(request);
        ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval);
    } else {
        ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:BennSandoval,项目名称:Woodmin,代码行数:17,代码来源:WoodminSyncAdapter.java

示例8: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();

        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:ArcadiusK,项目名称:spst,代码行数:20,代码来源:spotifystreamerSyncAdapter.java

示例9: setPeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Set synchronisation everyday with 4 hours flexible time
 * @param context
 * @param account
 */
private static void setPeriodicSync(Context context, Account account) {
    String authority = context.getResources().getString(R.string.content_authority);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(SYNC_INTERVAL, SYNC_FLEXTIME).
                setSyncAdapter(account, authority).
                setExtras(Bundle.EMPTY).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(
                account,
                authority,
                Bundle.EMPTY,
                SYNC_INTERVAL);
    }

    ContentResolver.setSyncAutomatically(account, context.getString(R.string.content_authority), true);
}
 
开发者ID:frank-tan,项目名称:Super-Duo,代码行数:26,代码来源:SyncAdapter.java

示例10: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule periodic execution of a sync adapter.
 * flexTime is only used on KitKat and newer devices.
 */
public static void configurePeriodicSync(Account account, String authority,
                                         int syncInterval, int flexTime) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder()
                .syncPeriodic(syncInterval, flexTime)
                .setSyncAdapter(account, authority)
                .setExtras(Bundle.EMPTY)
                .build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account, authority, Bundle.EMPTY, syncInterval);
    }
}
 
开发者ID:gengkev,项目名称:thyroxine,代码行数:20,代码来源:Utils.java

示例11: syncAsUser

import android.content.SyncRequest; //导入依赖的package包/类
public void syncAsUser(SyncRequest request, int userId) {
    Account account = mirror.android.content.SyncRequest.mAccountToSync.get(request);
    String authority = mirror.android.content.SyncRequest.mAuthority.get(request);
    Bundle extras = mirror.android.content.SyncRequest.mExtras.get(request);
    boolean isPeriodic = mirror.android.content.SyncRequest.mIsPeriodic.get(request);
    long syncRunTimeSecs = mirror.android.content.SyncRequest.mSyncRunTimeSecs.get(request);
    if (!isAccountExist(userId, account, authority)) {
        return;
    }
    VSyncRecord.SyncRecordKey key = new VSyncRecord.SyncRecordKey(account, authority);
    VSyncRecord.SyncExtras syncExtras = new VSyncRecord.SyncExtras(extras);
    int isSyncable = getIsSyncableAsUser(account, authority, userId);
    synchronized (mRecords) {
        Map<VSyncRecord.SyncRecordKey, VSyncRecord> map = mRecords.get(userId);
        if (map == null) {
            map = new HashMap<>();
            mRecords.put(userId, map);
        }
        VSyncRecord record = map.get(key);
        if (record == null) {
            record = new VSyncRecord(userId, account, authority);
            map.put(key, record);
        }
        if (isSyncable < 0) {
            // Initialisation sync.
            Bundle newExtras = new Bundle();
            newExtras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
            record.extras.add(new VSyncRecord.SyncExtras(newExtras));
        }
        if (isPeriodic) {
            VSyncRecord.PeriodicSyncConfig periodicSyncConfig = new VSyncRecord.PeriodicSyncConfig(syncRunTimeSecs);
            record.configs.put(syncExtras, periodicSyncConfig);
        } else {
            record.extras.add(syncExtras);
        }


    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:40,代码来源:VContentService.java

示例12: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
public static void configurePeriodicSync(Context context, long syncInterval, long flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(account, authority).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account,
                authority, new Bundle(), syncInterval);
    }
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:19,代码来源:TvGuideSyncAdapter.java

示例13: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
/**
 * Helper method to schedule the sync adapter periodic execution
 */
private static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        SyncRequest request = new SyncRequest.Builder().
                syncPeriodic(syncInterval, flexTime).
                setSyncAdapter(mAccount, context.getString(R.string.sync_authority)).
                setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(mAccount,
                context.getString(R.string.sync_authority), new Bundle(), syncInterval);
    }
}
 
开发者ID:DmitryMalkovich,项目名称:gito-github-client,代码行数:16,代码来源:SyncAdapter.java

示例14: startSynchronization

import android.content.SyncRequest; //导入依赖的package包/类
protected void startSynchronization() {
    Log_OC.d(TAG, "Got to start sync");
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
        Log_OC.d(TAG, "Canceling all syncs for " + MainApp.getAuthority());
        ContentResolver.cancelSync(null, MainApp.getAuthority());
        // cancel the current synchronizations of any ownCloud account
        Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " +
                MainApp.getAuthority());
        ContentResolver.requestSync(
                getAccount(),
                MainApp.getAuthority(), bundle);
    } else {
        Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " +
                MainApp.getAuthority() + " with new API");
        SyncRequest.Builder builder = new SyncRequest.Builder();
        builder.setSyncAdapter(getAccount(), MainApp.getAuthority());
        builder.setExpedited(true);
        builder.setManual(true);
        builder.syncOnce();

        // Fix bug in Android Lollipop when you click on refresh the whole account
        Bundle extras = new Bundle();
        builder.setExtras(extras);

        SyncRequest request = builder.build();
        ContentResolver.requestSync(request);
    }
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:32,代码来源:FileActivity.java

示例15: configurePeriodicSync

import android.content.SyncRequest; //导入依赖的package包/类
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
  Account account = getSyncAccount(context);
  String authority = context.getString(R.string.content_authority);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // we can enable inexact timers in our periodic sync
    SyncRequest request = new SyncRequest.Builder().
        syncPeriodic(syncInterval, flexTime).
        setSyncAdapter(account, authority).
        setExtras(new Bundle()).build();
    ContentResolver.requestSync(request);
  } else {
    ContentResolver.addPeriodicSync(account,
        authority, new Bundle(), syncInterval);
  }
}
 
开发者ID:nvh0412,项目名称:dealhunting,代码行数:16,代码来源:DealHuntingSyncAdapter.java


注:本文中的android.content.SyncRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。