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


Java PendingIntent.cancel方法代码示例

本文整理汇总了Java中android.app.PendingIntent.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java PendingIntent.cancel方法的具体用法?Java PendingIntent.cancel怎么用?Java PendingIntent.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.PendingIntent的用法示例。


在下文中一共展示了PendingIntent.cancel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTimeInterval

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setTimeInterval(Context context){
    Log.d(TAG, "Entered set time interval");
    Intent selfIntent = getIntent(context);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0,
            selfIntent, 0);

    AlarmManager manager = (AlarmManager) context.getSystemService
            (Context.ALARM_SERVICE);

    if (isTimeAlarmOn(context)){
        manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime(), REPEAT_TIME,
                pendingIntent);
        Log.d(TAG, "Alarm is not on, starting it now");
    }else {
        manager.cancel(pendingIntent);
        pendingIntent.cancel();
        Log.d(TAG, "Alarm is on, cancelling it now");
    }
}
 
开发者ID:aumarbello,项目名称:WalkGraph,代码行数:21,代码来源:TimeService.java

示例2: onSwiped

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
    int position = viewHolder.getAdapterPosition();

    AlarmRealmData deleteData = mResults.get(position);
    Log.d("Selected Position","Position:" + position);
    Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
    intent.setType(deleteData.getGeofenceId());
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
    pendingIntent.cancel();
    ((AlarmManager)getSystemService(ALARM_SERVICE)).cancel(pendingIntent);

    CustomRecyclerAdapter adapter = (CustomRecyclerAdapter)mBinding.recycler.getAdapter();
    adapter.removeItem(position);
    adapter.notifyDataSetChanged();
}
 
开发者ID:OldBigBuddha,项目名称:AlarmWithL-T,代码行数:17,代码来源:ShowDataActivity.java

示例3: setServiceAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setServiceAlarm(Context context, boolean isOn){
    Intent i = PollService.newIntent(context);
    // 创建一个用来启动PollService的PendingIntent
    PendingIntent pi = PendingIntent.getService(context, 0, i, 0);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    //设置或取消定时器
    if (isOn) {
        alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), POLL_INTERVAL, pi);
    } else {
        alarmManager.cancel(pi);
        pi.cancel();
    }
    QueryPreferences.setAlarmOn(context, isOn);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:18,代码来源:PollService.java

示例4: setServiceAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setServiceAlarm(Context context, boolean isOn) {
    Intent i = PollService.newIntent(context);
    PendingIntent pi = PendingIntent.getService(
            context, 0, i, 0);

    AlarmManager alarmManager = (AlarmManager)
            context.getSystemService(Context.ALARM_SERVICE);

    if (isOn) {
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), POLL_INTERVAL_MS, pi);
    } else {
        alarmManager.cancel(pi);
        pi.cancel();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:17,代码来源:PollService.java

示例5: setServiceAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setServiceAlarm(Context context, boolean isOn) {
    Intent i = PollService.newIntent(context);
    PendingIntent pi = PendingIntent.getService(
            context, 0, i, 0);

    AlarmManager alarmManager = (AlarmManager)
            context.getSystemService(Context.ALARM_SERVICE);

    if (isOn) {
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), POLL_INTERVAL_MS, pi);
    } else {
        alarmManager.cancel(pi);
        pi.cancel();
    }

    QueryPreferences.setAlarmOn(context, isOn);
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:19,代码来源:PollService.java

示例6: setTimeInterval

import android.app.PendingIntent; //导入方法依赖的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

示例7: cancelAlarm

import android.app.PendingIntent; //导入方法依赖的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

示例8: cancelRepeatingAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * Cancels the alarm that launches this service.  It will be replaced when Chrome next resumes.
 */
private void cancelRepeatingAlarm() {
    Intent requestIntent = createRegisterRequestIntent(this);
    PendingIntent pendingIntent =
            PendingIntent.getService(this, 0, requestIntent, PendingIntent.FLAG_NO_CREATE);
    // Setting FLAG_NO_CREATE forces Android to return an already existing PendingIntent.
    // Here it would be the one that was used to create the existing alarm (if it exists).
    // If the pendingIntent is null, it is likely that no alarm was created.
    if (pendingIntent != null) {
        AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        am.cancel(pendingIntent);
        pendingIntent.cancel();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:OmahaClient.java

示例9: stopTimer

import android.app.PendingIntent; //导入方法依赖的package包/类
void stopTimer() {
  PendingIntent pendingIntent =
      PendingIntent.getBroadcast(context, TimezOutBroadcast.TIMEZOUT_BROADCAST_REQUEST_CODE,
          intent, PendingIntent.FLAG_CANCEL_CURRENT);
  alarmManager.cancel(pendingIntent);
  pendingIntent.cancel();
}
 
开发者ID:jose96043,项目名称:TimezOut,代码行数:8,代码来源:TimerManager.java

示例10: deleteAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
private void deleteAlarm(Intent i, int requestCode){
    if(doesPendingIntentExist(i, requestCode)){
        PendingIntent pi = PendingIntent.getService(this, requestCode,i, PendingIntent.FLAG_NO_CREATE);
        pi.cancel();
        getAlarmManager().cancel(pi);
        Log.d("OskarSchindler", "PI Cancelled " + doesPendingIntentExist(i, requestCode));
    }
}
 
开发者ID:kotlin-korea,项目名称:Minimal-Todo,代码行数:9,代码来源:MainActivity.java

示例11: cancelNotificationAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * Cancels any notification alarm scheduled by the {@link freerunningapps.veggietizer.controller.BootReceiver}.
 * <p />
 * Once the user has opened the Veggietizer anyway, no reminder notification has to be triggered for today anymore.
 */
private void cancelNotificationAlarm() {
    Intent notifyIntent = new Intent(getApplicationContext(), NotificationService.class);
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(),
            BootReceiver.ALARM_REQUEST_ID, notifyIntent, 0);

    alarmManager.cancel(pendingIntent);
    pendingIntent.cancel();
}
 
开发者ID:mr-kojo,项目名称:Veggietizer,代码行数:15,代码来源:OverviewActivity.java

示例12: unregisterRegularUpdates

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * Cancel receiving of update alarm.
 */
private void unregisterRegularUpdates() {
    Log.d(TAG, "Canceling any alarm for regular updates");
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent updateIntent = createUpdateIntent(this);
    PendingIntent pendingIntent = PendingIntent.getService(this, 0, updateIntent, 0);
    alarmManager.cancel(pendingIntent);
    pendingIntent.cancel();
}
 
开发者ID:tbolender,项目名称:fefereader,代码行数:12,代码来源:UpdateService.java

示例13: setServiceAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setServiceAlarm(Context context, boolean isOn) {
    Intent i = PollService.newIntent(context);
    PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
    AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);

    if (isOn) {
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),
                POLL_INTERVAL_MS, pi);
    } else {
        alarmManager.cancel(pi);
        pi.cancel();
    }

    QueryPreferences.setAlarmOn(context, isOn);
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:16,代码来源:PollService.java

示例14: pushCancelLocalNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
public int pushCancelLocalNotification( int iIndex )
{
	//i)find item N in stored pending local notifications
	//Log.i("yoyo", "GCM: cancel alarm " + iIndex );
	String alarmData = getStoredPendingLocalAlarm( mContext, iIndex );
	if( alarmData != null )
	{
		//ii)extract id
		try 
		{
 		JSONObject jobj = new JSONObject(alarmData);
 		//String title = jobj.getString("title");
 		//String message = jobj.getString("message");
 		//String data = jobj.getString("data");
 		long time= jobj.getInt("time");
 		int uniqueID = (int)time;
 		
 		//iii)create a matching pending intent and cancel it
 		Context appContext = mContext.getApplicationContext();
     	Intent intent = new Intent( appContext, PushLocalAlarmReceiver.class);
     	PendingIntent pendingIntent = PendingIntent.getBroadcast(appContext, uniqueID, intent, PendingIntent.FLAG_ONE_SHOT);
 		
     	pendingIntent.cancel();
     	AlarmManager am = (AlarmManager)appContext.getSystemService(Context.ALARM_SERVICE);
     	am.cancel( pendingIntent);
 		
 		//iv)remove from the stored pending list
 		if( removeStoredLocalAlarm( mContext, iIndex ) )
 		{
 			//return success
 			return 1;
 		}
		}
		catch(Exception ex)
		{
			Log.i("yoyo", ex.toString());
		}
 		
	}
	
	//return fail status
	return 0;
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:44,代码来源:GcmPush.java

示例15: cancelRepeatingUpdates

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * Cancel all repeating alarms because the last fetch was a success.
 */
private void cancelRepeatingUpdates() {
    Intent updateIntent = new Intent(mContext, UpdateReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, ALARM_ID_ERROR, updateIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    pendingIntent.cancel();
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:9,代码来源:UpdateReceiver.java


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