如何在特定的小时在android中设置日历

我不想添加年份或月份。只需要每天的小时,分​​钟和秒钟。 如何使用它的日历对象来做到这一点? 这是我的代码

// 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); 

Related of "如何在特定的小时在android中设置日历"

尝试使用

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

也试试这个

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

注意: Months的值是MonthNumber-1Jan is 0Feb is 1等等)。