2015. 5. 26. 17:25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public void setAlarm(){ int year = 2012 ; int month = 10 ; int day = 20 ; int hour = 15 ; int minute = 30 ; AlarmManager alarm = (AlarmManager) this .getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(MainActivity. this , AlarmRecever. class ); PendingIntent pender = PendingIntent.getBroadcast(MainActivity. this , 0 , intent, 0 ); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1 , day, hour, minute); alarm.set(알람타입, calendar.getTimeInMillis(), pender); } |
I think you have problem in your "cal1" object;
When you set time in calendar object, actually setting Month, you should not use exact numeric value of month;
ex: - April = 4, you must use 3 instead of 4
I face this problem in API Level 19, but don't know about others.
This Question may give you better explanation.Why month give wrong value
public Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR,2014);
c.set(Calendar.MONTH, 03);//One minus from actual month numeric value
c.set(Calendar.DATE, 24);
c.set(Calendar.HOUR_OF_DAY,16 );
c.set(Calendar.MINUTE, 39);
c.set(Calendar.SECOND, 0);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(),pi);
'JAVA > Android' 카테고리의 다른 글
Android Thread , Handler , Looper , Message 관계 (336) | 2015.06.23 |
---|---|
안드로이드 Handler 사용방법 (166) | 2015.06.23 |
어플에서 SMS(문자) 전송 하기 (0) | 2015.05.11 |
[스크랩] Activity Flag (0) | 2015.04.13 |
다른 어플 실행 (0) | 2015.04.01 |