안드로이드 개발 질문/답변
(글 수 45,052)
알람 설정을 하려고 하는데요.
AlarmDB 라는 DB 를 만들어서 거기서 년(yy), 월(mm), 일(dd) 을 가지고 옵니다.
그리고 날짜가 되면 00시 00분에 알람을 하려고 합니다.
근데 시간설정을 cal.set(Calendar.~~~)로 해서 해봤는데 안되네요..ㅠ
그래서 책에 있는대로 그냥 현재시간 받고 10초 뒤에 울리라고
cal.add(Calendar.SECOND, 10); 을 줘서 해봤는데도... 알람은 울리지 않네요..ㅠ
책에는 버튼 이벤트로 버튼 눌렀을 때 알람이 되게 한것이고.. 저는 그냥 액티비티 실행하면 나오게 했는데요..
이문제는 아닐거라는 생각이라...
도와주십시오~ 하루종일 고민해봐도 소스가 뭐가 틀렸는지를 모르겠네요..ㅠ
public void AlarmSet(){
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent notiintent;
PendingIntent sender;
int yy = 2011;
int mm = 8;
int dd = 26;
int i=0;
notiintent = new Intent(this, AlarmNoti.class); //AlarmNoti.java 라는 Receive 를 만들어놨습니다.
sender = PendingIntent.getBroadcast(this, 0, notiintent, 0);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
//cal.set(yy, mm, dd);
//cal.set(Calendar.HOUR_OF_DAY, 16);
//cal.set(Calendar.MINUTE, 33);
//cal.set(Calendar.SECOND, 0);
am.set(AlarmManager.RTC, cal.getTimeInMillis(), sender);
}
AlarmDB 라는 DB 를 만들어서 거기서 년(yy), 월(mm), 일(dd) 을 가지고 옵니다.
그리고 날짜가 되면 00시 00분에 알람을 하려고 합니다.
근데 시간설정을 cal.set(Calendar.~~~)로 해서 해봤는데 안되네요..ㅠ
그래서 책에 있는대로 그냥 현재시간 받고 10초 뒤에 울리라고
cal.add(Calendar.SECOND, 10); 을 줘서 해봤는데도... 알람은 울리지 않네요..ㅠ
책에는 버튼 이벤트로 버튼 눌렀을 때 알람이 되게 한것이고.. 저는 그냥 액티비티 실행하면 나오게 했는데요..
이문제는 아닐거라는 생각이라...
도와주십시오~ 하루종일 고민해봐도 소스가 뭐가 틀렸는지를 모르겠네요..ㅠ
public void AlarmSet(){
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent notiintent;
PendingIntent sender;
int yy = 2011;
int mm = 8;
int dd = 26;
int i=0;
notiintent = new Intent(this, AlarmNoti.class); //AlarmNoti.java 라는 Receive 를 만들어놨습니다.
sender = PendingIntent.getBroadcast(this, 0, notiintent, 0);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
//cal.set(yy, mm, dd);
//cal.set(Calendar.HOUR_OF_DAY, 16);
//cal.set(Calendar.MINUTE, 33);
//cal.set(Calendar.SECOND, 0);
am.set(AlarmManager.RTC, cal.getTimeInMillis(), sender);
}