到目前为止,由于这个网站,我已经能够设置一个即使我打开手机也会设置并激活的闹钟.
现在,我设置了一个警报,显示事件A的提示,我需要应用程序设置另一个警报,以显示事件B的另一个提醒.
我必须做错事,因为它只会触发事件A的提醒.似乎一旦设置,任何其他警报都被理解为同一个警报.:-(
以下是两步中我正在做的细节:
1)从一项活动中我设置了一个警报,在某个时间和日期将呼叫接收者
Intent intent = new Intent(Activity_Reminder.this,
AlarmReceiver_SetOnService.class);
intent.putExtra("item_name", prescription
.getItemName());
intent
.putExtra(
"message",
Activity_Reminder.this
.getString(R.string.notif_text));
intent.putExtra("item_id", itemId);
intent.putExtra("activityToTrigg",
"com.companyName.appName.main.Activity_Reminder");
PendingIntent mAlarmSender;
mAlarmSender = PendingIntent.getBroadcast(
Activity_Reminder.this, 0, intent, 0);
long alarmTime = dateMgmt.getTimeForAlarm(pickedDate);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(alarmTime);
// Schedule the alarm!
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, alarmTime + 15000,
mAlarmSender);
Run Code Online (Sandbox Code Playgroud)
2)从接收器我呼叫服务
Bundle bundle = intent.getExtras();
String itemName = bundle.getString("item_name");
String reminderOrAlarmMessage = bundle.getString("message");
String activityToTrigg = bundle.getString("activityToTrigg");
int itemId = Integer.parseInt(bundle.getString("item_id"));
NotificationManager nm …Run Code Online (Sandbox Code Playgroud) 我正在安排任务并根据日期和时间添加警报管理器,并且计划任务正在添加到列表中..当我添加任何任务时,它还在sqlite数据库中添加并为警报管理器分配pendinng意图的唯一ID.
现在,如果我想取消警报,那么如果我从列表中删除该行,那么我也想解除该特定警报..我能够从数据库中删除行但是如何解除该行的警报集?
我的代码如下:
Button AddData=(Button)findViewById(R.id.senddata);
AddData.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);
Date= updatedate.getText().toString();
Time= updateTime.getText().toString();
Discripton= discription.getText().toString();
//---get current date and time---
Calendar calendar = Calendar.getInstance();
//---sets the time for the alarm to trigger---
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, mHour);
calendar.set(Calendar.MINUTE, mMinute);
calendar.set(Calendar.SECOND, 0);
Log.i("********####",year+" ,"+month+" , "+day+" , "+mHour+" , "+mMinute+"----"+ calendar.getTimeInMillis());
Intent intent = new Intent(AddEditExpense.this, TimeAlarm.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Bundle b12 …Run Code Online (Sandbox Code Playgroud)