首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在android中设置特定时间的日期?

如何在android中设置特定时间的日期?

提问于 2018-01-29 04:42:21
回答 2关注 0查看 182

我不想再加一年或一个月。每天只有一小时、几分钟和几秒。如何使用Calendar对象来完成它?这是我的密码

代码语言:txt
复制
// 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);

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档