Подтвердить что ты не робот

Как настроить календарь в Android для определенного часа

Я не хочу добавлять год или месяц. Просто час, минуты и секунды для каждого дня. Как использовать объект Calendar для этого? Это мой код

// get a Calendar object with current time
Calendar cal = Calendar.getInstance();
// add 5 minutes to the calendar object

cal.add(Calendar.HOUR, 4);
cal.add(Calendar.MINUTE, 40);




Intent i = new Intent(this, Receiver.class);
i.putExtra("alarm_message", "O'Doyle Rules!");
// In reality, you would want to have a static variable for the request code instead of 192837
PendingIntent sender = PendingIntent.getBroadcast(this, 192837, i, PendingIntent.FLAG_UPDATE_CURRENT);

// Get the AlarmManager service
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
4b9b3361

Ответ 1

попробуйте использовать

calendar.set(Calendar.HOUR_OF_DAY, 4);
calendar.set(Calendar.MINUTE, 40);
calendar.set(Calendar.SECOND, 0);

Ответ 2

попробуйте это тоже

cal.set(2013,2,7,15,42,30);

Примечание: Значение месяца MonthNumber-1 (Jan is 0, Feb is 1 и т.д.).