本文整理汇总了Java中com.google.android.apps.iosched.sync.TriggerSyncReceiver类的典型用法代码示例。如果您正苦于以下问题:Java TriggerSyncReceiver类的具体用法?Java TriggerSyncReceiver怎么用?Java TriggerSyncReceiver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TriggerSyncReceiver类属于com.google.android.apps.iosched.sync包,在下文中一共展示了TriggerSyncReceiver类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scheduleSync
import com.google.android.apps.iosched.sync.TriggerSyncReceiver; //导入依赖的package包/类
private void scheduleSync(Context context, int syncDelay) {
// Use delay instead of jitter, since we're trying to squelch messages
int jitterMillis = syncDelay;
final String debugMessage = "Scheduling next sync for " + jitterMillis + "ms";
LOGI(TAG, debugMessage);
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE))
.set(
AlarmManager.RTC,
System.currentTimeMillis() + jitterMillis,
PendingIntent.getBroadcast(
context,
0,
new Intent(context, TriggerSyncReceiver.class),
PendingIntent.FLAG_CANCEL_CURRENT));
}
示例2: scheduleSync
import com.google.android.apps.iosched.sync.TriggerSyncReceiver; //导入依赖的package包/类
private void scheduleSync(Context context, int syncJitter) {
int jitterMillis = (int) (RANDOM.nextFloat() * syncJitter);
final String debugMessage = "Scheduling next sync for " + jitterMillis + "ms";
LOGI(TAG, debugMessage);
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE))
.set(
AlarmManager.RTC,
System.currentTimeMillis() + jitterMillis,
PendingIntent.getBroadcast(
context,
0,
new Intent(context, TriggerSyncReceiver.class),
PendingIntent.FLAG_CANCEL_CURRENT));
}
示例3: onMessage
import com.google.android.apps.iosched.sync.TriggerSyncReceiver; //导入依赖的package包/类
@Override
protected void onMessage(Context context, Intent intent) {
if (UIUtils.isGoogleTV(context)) {
// Google TV uses SyncHelper directly.
return;
}
String announcement = intent.getStringExtra("announcement");
if (announcement != null) {
displayNotification(context, announcement);
return;
}
int jitterMillis = (int) (sRandom.nextFloat() * TRIGGER_SYNC_MAX_JITTER_MILLIS);
final String debugMessage = "Received message to trigger sync; "
+ "jitter = " + jitterMillis + "ms";
LOGI(TAG, debugMessage);
if (BuildConfig.DEBUG) {
displayNotification(context, debugMessage);
}
((AlarmManager) context.getSystemService(ALARM_SERVICE))
.set(
AlarmManager.RTC,
System.currentTimeMillis() + jitterMillis,
PendingIntent.getBroadcast(
context,
0,
new Intent(context, TriggerSyncReceiver.class),
PendingIntent.FLAG_CANCEL_CURRENT));
}