计时器从Notification RemoteViews中的特定值开始 [英] Chronometer start from specific value in Notification RemoteViews
本文介绍了计时器从Notification RemoteViews中的特定值开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试在新的通知中启动计时器,但是从暂停(经过)开始,经过的时间是从另一个计时器获得的",而不是从零开始计时
I'm trying to start the chronometer in a new notification but from a paused(elapsed) "the elapsed time is got from another chronometer", not from zero
天文钟表的通知 RemoteViews.class
中的开始 base
与 Chronometer.class
的开始base不同,它具有不同的计算>
The start base
in Notification RemoteViews.class
of chronometer is different from the start base in Chronometer.class
it has different calculations
Notification notification = new
NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(songName).build();
notification.contentView = simpleContentView;
然后我得到 timeWhenPaused
long timeWhenPaused = myChronometer.getBase() - SystemClock.elapsedRealtime();
然后创建天文钟
notification.contentView.setChronometer(R.id.chronometer_recorder
, (SystemClock.elapsedRealtime() + timeWhenPaused)
, null
, true
);
从零开始
推荐答案
我尝试了许多计算方法,终于得到了这个.
I tried many method with calculations finally got this.
long elapsedMillis = SystemClock.elapsedRealtime() - myChronometer.getBase();
然后
notification.contentView.setChronometer(R.id.chronometer_recorder_notification
,(SystemClock.elapsedRealtime() - elapsedMillis ^5)
,null
,true
);
这篇关于计时器从Notification RemoteViews中的特定值开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文