第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用cancel()從AlarmManager刪除警報(bào)-Android

使用cancel()從AlarmManager刪除警報(bào)-Android

我試圖用兩種不同的方法創(chuàng)建和刪除警報(bào),這兩種方法在應(yīng)用程序邏輯中的不同時(shí)刻都被調(diào)用。但是,當(dāng)我調(diào)用AlarmManager的cancel()方法時(shí),不會(huì)刪除警報(bào)。這是我的addAlarm()方法:AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);Intent intent = new Intent(PROX_ALERT_INTENT);intent.putExtra("ALERT_TIME", alert.date);intent.putExtra("ID_ALERT", alert.idAlert);intent.putExtra("TITLE", alert.title);intent.putExtra("GEO_LOC", alert.isGeoLoc);PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,        alert.idAlert, intent, PendingIntent.FLAG_CANCEL_CURRENT);Calendar calendar = Calendar.getInstance();calendar.setTime(alert.date);alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);Log.e("ADD ALERT - WithoutGeoLoc - ",alert.toString());這是我的deleteAlarm()方法:AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);Intent intent = new Intent(PROX_ALERT_INTENT);intent.putExtra("ALERT_TIME", alert.date);intent.putExtra("ID_ALERT", alert.idAlert);intent.putExtra("TITLE", alert.title);intent.putExtra("GEO_LOC", alert.isGeoLoc);PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,        alert.idAlert, intent, PendingIntent.FLAG_CANCEL_CURRENT);alarmManager.cancel(pendingIntent);Log.e(TAG,"REMOVE ALERT - without GeoLoc"+alert.toString());這是我的Logcat:01-23 17:44:07.411: E/ADD ALERT - WithoutGeoLoc -(18789): Alert [latitude=0.0, longitude=0.0, title=bfwu, comments=null, address=null, currency=hrk, idAlert=1, date=Sat Feb 23 17:44:04 CET 2013, isGeoLoc=null]01-23 17:44:13.032: E/REMOVE ALERT without GeoLoc - (18789): Alert [latitude=0.0, longitude=0.0, title=bfwu, comments=null, address=null, currency=hrk, idAlert=1, date=Sat Feb 23 17:44:04 CET 2013, isGeoLoc=null]幾個(gè)注意事項(xiàng):RTC_WAKEUP #47 是我的原始警報(bào)RTC_WAKEUP #48 是應(yīng)該覆蓋#47而不是創(chuàng)建新警報(bào)的新警報(bào)。我使用filterEquals()返回的true...的Intent 方法比較了我的add和delete方法中的兩個(gè)intent(不是前瞻性Intents),但是沒(méi)有刪除警報(bào)。我究竟做錯(cuò)了什么?
查看完整描述

3 回答

?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

試試這個(gè)標(biāo)志:


PendingIntent.FLAG_UPDATE_CURRENT

代替:


PendingIntent.FLAG_CANCEL_CURRENT 

因此,PendingIntent將如下所示:


PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 

        alert.idAlert, intent, PendingIntent.FLAG_UPDATE_CURRENT)  

(確保使用相同的alert對(duì)象和mContext!)


旁注:如果要一個(gè)全局AlarmManager,請(qǐng)將AlarmManager放在靜態(tài)變量中(并且僅在時(shí)將其初始化null)。


查看完整回答
反對(duì) 回復(fù) 2019-12-27
?
慕田峪9158850

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超7個(gè)贊

在設(shè)置的任何特定時(shí)間從警報(bào)管理器中取消警報(bào):


Intent intent = new Intent(context, AlarmReceiver.class);

PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE);

am.cancel(pendingIntent);


查看完整回答
反對(duì) 回復(fù) 2019-12-27
  • 3 回答
  • 0 關(guān)注
  • 1189 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)