以毫秒为单位的时间报警
好的,所以我正在制作一个发出通知的闹钟,比如说每天下午3点,但是我希望用户可以选择这个,AM / PM和小时/分钟之间可以自由更改。我可能会使用
TimePicker
,这是我到目前为止的代码:
public void startAlarm() {
Intent intent = new Intent(currentDay.this, AlarmReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(currentDay.this,0, intent,0);
long firstTime = SystemClock.elapsedRealtime();
firstTime += 15*1000;
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime,AlarmManager.INTERVAL_DAY, sender);
}
所以,我认为我将使用以下内容:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 19);
cal.set(Calendar.MINUTE, 45);
然后使用
cal.getTimeInMillis()
但这不起作用,任何想法?谢谢!
编辑:所以,长话短说,我知道如何获得当前时间,然后添加让我们说15秒,但我想有一个确定的时间工作例如下午5:14,我尝试的一切都没有不行
没有找到相关结果
已邀请:
1 个回复
田眯衅
编辑:将当地时间转换为UTC ...
注意:我没有尝试过上述内容,可能有一种更简单的方法,但它应该可以工作。我很难测试这样的东西,因为我的时区是GMT / UTC。