當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。