本文整理汇总了Java中android.app.AlarmManager.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java AlarmManager.cancel方法的具体用法?Java AlarmManager.cancel怎么用?Java AlarmManager.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlarmManager
的用法示例。
在下文中一共展示了AlarmManager.cancel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTimeInterval
import android.app.AlarmManager; //导入方法依赖的package包/类
public static void setTimeInterval(Context context, boolean isOn){
Intent selfIntent = IndividualService.getIntent(context);
PendingIntent pendingIntent = PendingIntent.getService(context, 0,
selfIntent, 0);
AlarmManager manager = (AlarmManager) context.getSystemService
(Context.ALARM_SERVICE);
if (isOn){
manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime(), alarmInterval,
pendingIntent);
}else {
manager.cancel(pendingIntent);
pendingIntent.cancel();
}
}
示例2: onReceive
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
long scheduledTime = getNextScheduledExecutionTime(context);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent alarmIntent = new Intent(context, getClass());
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
if (System.currentTimeMillis() >= scheduledTime) {
scheduledTime = onAlarm(context, scheduledTime);
}
Log.w(TAG, getClass() + " scheduling for: " + scheduledTime);
alarmManager.cancel(pendingIntent);
alarmManager.set(AlarmManager.RTC_WAKEUP, scheduledTime, pendingIntent);
}
示例3: schedule
import android.app.AlarmManager; //导入方法依赖的package包/类
/**
* Schedule or cancel this service to update the app index, according to the
* current preferences. Should be called a) at boot, b) if the preference
* is changed, or c) on startup, in case we get upgraded.
*/
public static void schedule(Context context) {
long keepTime = Preferences.get().getKeepCacheTime();
long interval = TimeUnit.DAYS.toMillis(1);
if (keepTime < interval) {
interval = keepTime;
}
Intent intent = new Intent(context, CleanCacheService.class);
PendingIntent pending = PendingIntent.getService(context, 0, intent, 0);
AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pending);
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + 5000, interval, pending);
}
示例4: deleteAllReminders
import android.app.AlarmManager; //导入方法依赖的package包/类
/**
* Delete the all reminders
* @param context - the current app context
*/
public void deleteAllReminders(Context context) {
AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE);
for (int i = 0; i < mPlantsNumber; i++) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, i, new Intent(context, BirthdayReceiver.class), 0);
if (am != null) {
am.cancel(pendingIntent);
pendingIntent = PendingIntent.getBroadcast(context, i, new Intent(context, FertilizerReceiver.class), 0);
am.cancel(pendingIntent);
pendingIntent = PendingIntent.getBroadcast(context, i, new Intent(context, HeightMeasureReceiver.class), 0);
am.cancel(pendingIntent);
pendingIntent = PendingIntent.getBroadcast(context, i, new Intent(context, UpdatePhotoReceiver.class), 0);
am.cancel(pendingIntent);
pendingIntent = PendingIntent.getBroadcast(context, i, new Intent(context, WaterReceiver.class), 0);
am.cancel(pendingIntent);
}
}
}
示例5: onStartCommand
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
boolean isUpdateTime = pref.getBoolean("isUpdateTime", true);
if (isUpdateTime == true){
updateWeather();
AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
int autoUpdateTime = pref.getInt("autoUpdateTime", 60);
int anHour = autoUpdateTime * 60 * 1000; // 这是 60 分钟的毫秒数
long triggerAtTime = SystemClock.elapsedRealtime() + anHour;
Intent i = new Intent(this, AutoUpdateService.class);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
manager.cancel(pi);
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
}
return super.onStartCommand(intent, flags, startId);
}
示例6: onStartCommand
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
updateWeather();
updateBingPic();
AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
int anHour = 8 * 60 * 60 * 1000; // 这是8小时的毫秒数
long triggerAtTime = SystemClock.elapsedRealtime() + anHour;
Intent i = new Intent(this, AutoUpdateService.class);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
manager.cancel(pi);
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
return super.onStartCommand(intent, flags, startId);
}
示例7: onStartCommand
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
updateWeather();
updateBingPic();
AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
int anHour = 8 * 60 * 60 * 1000; //8小时
long triggerAtTime = SystemClock.elapsedRealtime() + anHour; //系统开机至今的时间+8小时
Intent i = new Intent(this, AutoUpdateService.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
manager.cancel(pi);
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
return super.onStartCommand(intent, flags, startId);
}
示例8: stopPushService
import android.app.AlarmManager; //导入方法依赖的package包/类
public static void stopPushService() {
applicationContext.stopService(new Intent(applicationContext, NotificationsService.class));
PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0);
AlarmManager alarm = (AlarmManager)applicationContext.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pintent);
}
示例9: onStartCommand
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
updateWeather();
updateBingPic();
AlarmManager manager=(AlarmManager)getSystemService(ALARM_SERVICE);
int anHour=1*60*60*1000;//这是1小时的毫秒数
long triggerAtTime= SystemClock.elapsedRealtime()+anHour;
Intent i=new Intent(this,AutoUpdateService.class);
PendingIntent pi=PendingIntent.getService(this,0,i,0);
manager.cancel(pi);
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,triggerAtTime,pi);
return super.onStartCommand(intent,flags,startId);
}
示例10: cancelAlarm
import android.app.AlarmManager; //导入方法依赖的package包/类
/**
* Attempts to cancel any alarms set using the given Intent.
* @param scheduledIntent Intent that may have been previously scheduled.
* @return whether or not an alarm was canceled.
*/
public boolean cancelAlarm(Intent scheduledIntent) {
PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, scheduledIntent,
PendingIntent.FLAG_NO_CREATE);
if (pendingIntent != null) {
AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
am.cancel(pendingIntent);
pendingIntent.cancel();
return true;
} else {
return false;
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:ExponentialBackoffScheduler.java
示例11: a
import android.app.AlarmManager; //导入方法依赖的package包/类
public static void a(Context context, PendingIntent pendingIntent, int i) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService("alarm");
alarmManager.cancel(pendingIntent);
Calendar instance = Calendar.getInstance();
instance.setTimeInMillis(System.currentTimeMillis());
instance.add(14, i);
alarmManager.set(0, instance.getTimeInMillis(), pendingIntent);
}
示例12: unalarm
import android.app.AlarmManager; //导入方法依赖的package包/类
public void unalarm(int id) {
int requestCode = id;
Intent intent = new Intent(Festival.aFestival,
FestivalClockActivity.class);
PendingIntent pi = PendingIntent.getActivity(Festival.aFestival,
requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT); // ����id���ò�ͬ������
// And cancel the alarm.
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.cancel(pi);
Toast.makeText(getApplicationContext(), "����ȡ����", Toast.LENGTH_LONG)
.show();
}
示例13: cancelAlarm
import android.app.AlarmManager; //导入方法依赖的package包/类
private void cancelAlarm(Context context, PendingIntent pendingIntent) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
try {
alarmManager.cancel(pendingIntent);
} catch (Throwable t) {
t.printStackTrace();
}
}
示例14: onStartCommand
import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
updateWeather();
updateBingPic();
AlarmManager manager = (AlarmManager)getSystemService(ALARM_SERVICE);
int eightHour = 8*60*60*1000;//八个小时的毫秒数
long triggerAtTime = SystemClock.elapsedRealtime()+eightHour;
Intent i = new Intent(this, AutoUpdateService.class);
PendingIntent pi = PendingIntent.getService(this,0,i,0);
manager.cancel(pi);
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,triggerAtTime,pi);
return super.onStartCommand(intent, flags, startId);
}
示例15: startTimeoutIfAppropriate
import android.app.AlarmManager; //导入方法依赖的package包/类
private void startTimeoutIfAppropriate() {
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(this);
if ((activitiesRunning == 0) && (KeyCachingService.masterSecret != null) && timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(this)) {
long timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(this);
long timeoutMillis = TimeUnit.MINUTES.toMillis(timeoutMinutes);
Log.w("KeyCachingService", "Starting timeout: " + timeoutMillis);
AlarmManager alarmManager = (AlarmManager)this.getSystemService(ALARM_SERVICE);
alarmManager.cancel(pending);
alarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + timeoutMillis, pending);
}
}