對不起,如果這個問題有點誤導。如何在日曆對象中設置選擇時間?
我剛纔問了另外一個問題,並在我的幫助下得到了這個結果。這是問題。
我應該在特定時間啓動服務。現在...如果我使用Calendar對象中的當前時間立即啓動服務,但服務開始,但是當我手動設置時間時,服務不會啓動。這裏的代碼:
Calendar myCal = Calendar.getInstance();
myCal.set(Calendar.HOUR_OF_DAY, 21);
myCal.set(Calendar.MINUTE, 4);
// Will use putExtras here to give service the details of which profile to activate
Intent intent = new Intent(Create.this, AutoBot.class);
PendingIntent pintent = PendingIntent.getService(Create.this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, myCal.getTimeInMillis(), 5*1000, pintent);
現在這應該在技術上工作,但它不是。這就是爲什麼我需要你的幫助:(
而且,如果我有多個觸發(報警器本身),你會setRepeating的第三個參數是什麼?
但我正在使用當前日期/時間初始化日曆對象。爲什麼我需要改變它?你可以解釋一下我需要放入Calendar.DATE/YEAR嗎? – Asim 2012-04-07 18:40:34