特定のアラームをキャンセルすることに問題があります。アラームマネージャのSETメソッドを使用して複数のアラームを設定しています。しかし、私は特定のアラームをキャンセルすることはできません。キャンセルすると、以前に設定したアラームがすべてキャンセルされます。私は複数のアラームを設定するために単一のALARM MANAGER IDを使用しています。特定のアラームをキャンセルするには?
SAVE METHOD
private void saveState()
{
// String date = mDateText.getText().toString();
String title = mTitleText.getText().toString();
String body = mBodyText.getText().toString();
String sdate = sDateText.getText().toString();
String stime = sTimeText.getText().toString();
String rdate = rDateText.getText().toString();
String rtime = rTimeText.getText().toString();
String appRemDate = ((Button)findViewById(R.id.enterdaterem)).getText().toString();
String appRemTime = ((Button)findViewById(R.id.entertimerem)).getText().toString();
Calendar cal = Calendar.getInstance();
//setting date & month
if(appRemDate.substring(0,2).endsWith("-") && appRemDate.substring(2,4).endsWith("-"))
{
cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(4,8)));
cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(2,3)) -1);
cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,1)));
}
else if(!appRemDate.substring(0,2).contains("-") && !appRemDate.substring(3,5).contains("-"))
{
cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(6,10)));
cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(3,5)) -1);
cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,2)));
}
else if(appRemDate.substring(0,2).endsWith("-") && !appRemDate.substring(2,4).endsWith("-"))
{
cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(5,9)));
cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(2,4)) -1);
cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,1)));
}
else
{
cal.set(Calendar.YEAR, Integer.parseInt(appRemDate.substring(5,9)));
cal.set(Calendar.MONTH, Integer.parseInt(appRemDate.substring(3,4)) -1);
cal.set(Calendar.DATE, Integer.parseInt(appRemDate.substring(0,2)));
}
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(appRemTime.substring(0, 2)));
cal.set(Calendar.MINUTE, Integer.parseInt(appRemTime.substring(3, 5)));
cal.set(Calendar.SECOND, 0);
if (mRowId == null)
{
long id = mDbHelper.createNote( title, body, sdate, stime, rdate, rtime);
invokeAlaram(cal.getTimeInMillis(), id);
if (id > 0)
{
mRowId = id;
}
}
else
{
long id = mDbHelper.updateNote(mRowId, title, body, sdate, stime, rdate, rtime);
invokeAlaram(cal.getTimeInMillis(), id);
}
}
INVOKEのALARM METHOD
private void invokeAlaram(long invokeTime, long id)
{
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
Intent i = new Intent(this, MyAlarmServiceForAppointments.class);
i.putExtra("rowId", String.valueOf(id));
am.set(AlarmManager.RTC_WAKEUP, invokeTime, PendingIntent.getService(this , (int) System.currentTimeMillis() ,i , 0));
}
誰もが特定のアラームを解除する方法を手伝ってくれる。ここ
am.set(AlarmManager.RTC_WAKEUP, invokeTime, PendingIntent.getService(this , (int) System.currentTimeMillis() ,i , 0));
代わりのシステム時刻を使用して、あなたは、要求が特定の意図のために異なっていたとして考えるあなたの固有の番号を渡すために持っているよう