亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Toast 消息在 Android 通知設置期間顯示兩次

Toast 消息在 Android 通知設置期間顯示兩次

largeQ 2023-04-26 15:37:17
我在 Android 應用程序中有一個選項可以設置兩個通知?;旧希斢脩魡螕舭粹o時,將顯示一個時間選擇器,在第一次選擇器完成后,將彈出第二個時間選擇器供用戶第二次插入。兩個時間選擇器都在不同的方法中,在第一種方法結束時顯示吐司,與第二種方法相同。問題是當第一次選擇器完成時,兩條吐司消息立即觸發,然后當用戶第二次完成選擇器時,第二條吐司消息再次觸發。我已經包含了下面的代碼。 /** * Method which sets the first daily notification */private void startTwiceDailyNotification(Calendar c) {    DialogFragment timePicker = new TimePickerFragment();    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);    Intent intent = new Intent(this, AlertReceiver.class);    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);    alarmManager.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);    Toast.makeText(this, "First Notification Set.", Toast.LENGTH_SHORT).show();    timePicker.show(getSupportFragmentManager(), "time picker4");    hasSelected = 2;}/** * Method which sets the second daily notification */private void startTwiceDailyNotification2(Calendar c) {    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);    Intent intent = new Intent(this, AlertReceiver.class);    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 2, intent, 0);    alarmManager.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);    Toast.makeText(this, "Second Notification Set.", Toast.LENGTH_SHORT).show();}
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號