我想要在用戶簽入複選框時發出警報。這裏是我的代碼:Android日曆始終與日期相同
if (cb1.isChecked())
{
Calendar calA = Calendar.getInstance();
//calA.set(Calendar.YEAR, Calendar.YEAR);
//calA.set(Calendar.MONTH, Calendar.MONTH);
//calA.set(Calendar.DAY_OF_MONTH, Calendar.DAY_OF_MONTH);
calA.set(Calendar.HOUR_OF_DAY, Calendar.HOUR_OF_DAY);
calA.set(Calendar.MINUTE, Calendar.MINUTE);
calA.set(Calendar.SECOND, Calendar.SECOND);
calA.set(Calendar.MILLISECOND, Calendar.MILLISECOND);
alarmManager.set(AlarmManager.RTC_WAKEUP, calA.getTimeInMillis(), pendingIntentA);
Toast.makeText(main.this, "Set time: " + String.valueOf(calA.getTime()), Toast.LENGTH_SHORT).show();
}
其他代碼工作正常,如果我設定的小時和分鐘來具體的,如
calA.set(Calendar.HOUR_OF_DAY, 15);
calA.set(Calendar.MINUTE, 24);
它的工作,但與此代碼我總是得到這個吐司消息: Sat Mar 05 11:12:00或Sat Mar 05 11:12:13 (日期和時間都不好)
我的代碼出了什麼問題?
好的。我試過這個:\t \t Calendar now = Calendar.getInstance(); \t \t alarmManager.set(AlarmManager.RTC_WAKEUP,now.getTimeInMillis(),pendingIntentA); – erdomester 2011-01-30 14:06:27