If you think the Android project Tasque-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.bustiblelemons.tasque.frontend;
/*fromwww.java2s.com*/importstatic com.bustiblelemons.tasque.utilities.Values.TAG;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.bustiblelemons.tasque.rtm.RTMSyncBroadcastReceiver;
import com.bustiblelemons.tasque.rtm.RTMSyncService;
import com.bustiblelemons.tasque.settings.SettingsUtil;
/**
* Created 31 May 2013
*/publicclass Alarms {
publicstaticvoid cancel(Context context) {
Log.d(TAG, "Canceling alarms for updates");
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, RTMSyncService.class);
PendingIntent pending = PendingIntent.getService(context, RTMSyncService.REQUEST_CODE, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
pending.cancel();
manager.cancel(pending);
}
publicstaticvoid setUp(Context context) {
// int intervalMillis = SettingsUtil.getRTMIntervalUpdate(context);
// FIXME Still doesn't fire up properly
Alarms.cancel(context);
int intervalMillis = SettingsUtil.getRTMIntervalUpdate(context);
if (intervalMillis > 0) {
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, RTMSyncBroadcastReceiver.class);
PendingIntent pending = PendingIntent.getBroadcast(context, RTMSyncService.REQUEST_CODE, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Log.d(TAG, "Another update in " + (intervalMillis / 1000) / 60 + " minutes.");
manager.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis() + intervalMillis, intervalMillis,
pending);
} else {
Log.d(TAG, "There will be no updates");
}
}
}