3
請您好好看看這個。我正在設置特定時間和日期的鬧鐘。它似乎沒有工作,我不知道爲什麼。在Android中將鬧鐘設置爲特定日期和時間
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.YEAR, mYear);
cal.set(Calendar.MONTH,mMonth);
cal.set(Calendar.DAY_OF_MONTH,mDay);
cal.set(Calendar.HOUR,mHour);
cal.set(Calendar.MINUTE,mMinutes);
// where mYear, mMonths, mDay, mHour and mMinutes are int values from the Date and Time picker dialogs respectively
Intent activate = new Intent(this, Alarm.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, activate, 0);
alarms = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
只是爲了讓你知道,它的作品,如果我更換cal.getTimeInMillis()與System.CurrentTimeInMillis()在alarms.set()方法。但那顯然是我不想要的。謝謝
你把自己罵成白癡!錯誤是學習的步驟,以使你成爲碩士..... – 2010-09-21 08:59:34