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


Java AlarmManager.cancel方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:aumarbello,项目名称:Tasks,代码行数:18,代码来源:IndividualService.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:17,代码来源:PersistentAlarmManagerListener.java

示例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);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:CleanCacheService.java

示例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);
        }
    }
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:22,代码来源:DatabaseManager.java

示例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);
}
 
开发者ID:lentitude,项目名称:BS-Weather,代码行数:18,代码来源:AutoUpdateService.java

示例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);
}
 
开发者ID:zjutcmos,项目名称:HappyWeather,代码行数:14,代码来源:AutoUpdateService.java

示例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);
}
 
开发者ID:Yjnull,项目名称:CoolMasterWeather,代码行数:15,代码来源:AutoUpdateService.java

示例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);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ApplicationLoader.java

示例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);
}
 
开发者ID:Qinlong275,项目名称:AndroidBookTest,代码行数:14,代码来源:AutoUpdateService.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:i.java

示例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();
}
 
开发者ID:z9961,项目名称:DoList,代码行数:14,代码来源:FestivalEditActivity.java

示例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();
    }
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:10,代码来源:AttackManager.java

示例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);
}
 
开发者ID:fczdev,项目名称:nowweather,代码行数:14,代码来源:AutoUpdateService.java

示例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);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:KeyCachingService.java


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