0
현재 작업중인 프로젝트에 알람이 추가되었습니다. 그들은 내 모든 조건에 잘 작동합니다. 하나의 작은 문제에 직면. 원샷 알람을 추가했습니다. 정시에 발사하기를 원합니다. 잘 작동하고 시간이 지나면 내가 의도를 통해 전송하는 값으로 활동을 시작합니다. 알람이 시작된 후에도 문제가 발생했습니다. 보류중인 인 텐트가 다시 호출되고 해당 활동을 닫으면 null 값을 사용하여 활동이 열립니다. 닫으면 그 횟수만큼 다시 팝업됩니다. 보류중인 의도가 지정된 시간에 해고 된 후에 취소되지 않습니다. 아래는 알람을 설정하는 코드입니다.계속 보류중인 알람 보류 의도가
public void setAlarm(int hours, int minutes,String AMPM, String alarmType,String message, String extraMessage)
{
Random rand = new Random();
int n = rand.nextInt(10000) + 1;
Log.e("HMA",hours+" "+minutes+" "+AMPM + " " + message + extraMessage);
// Toast.makeText(getApplicationContext(), "Alarm On",
// Toast.LENGTH_SHORT).show();
Calendar calendar = Calendar.getInstance();
// set selected time from timepicker to calendar
calendar.set(Calendar.HOUR_OF_DAY, hours);
calendar.set(Calendar.MINUTE,minutes);
calendar.set(Calendar.SECOND,00);
if(AMPM.equals("PM")) {
Log.e("PM","");
calendar.set(Calendar.AM_PM, Calendar.PM);
}
else
{
calendar.set(Calendar.AM_PM, Calendar.AM);
}
Intent myIntent = new Intent(this,
MyReceiver.class);
AlarmManager alarmManager;
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
myIntent.putExtra("alarmType",alarmType);
myIntent.putExtra("gifMessage",message);
myIntent.putExtra("extraMessage",extraMessage);
PendingIntent pendingIntent;
// A PendingIntent specifies an action to take in the
// future
pendingIntent = PendingIntent.getBroadcast(
this, n, myIntent, 0);
// set alarm time
if(Build.VERSION.SDK_INT<19) {
alarmManager.set(AlarmManager.RTC,
calendar.getTimeInMillis(), pendingIntent);
}
else if(Build.VERSION.SDK_INT>=19 && Build.VERSION.SDK_INT<=22)
{
alarmManager.setExact(AlarmManager.RTC,
calendar.getTimeInMillis(), pendingIntent);
}
else if(Build.VERSION.SDK_INT>=23)
{
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC,
calendar.getTimeInMillis(), pendingIntent);
}
}
오류 메시지와이 클래스의 전체 코드를 게시하십시오. – Raja