我正在尝试在新通知中启动秒表,但是从已暂停(经过的)时间开始(“经过的时间来自另一个秒表”),而不是从零开始
通知RemoteViews.class
中的秒表启动base
与Chronometer.class
中的启动基数不同,它有不同的计算方式
Notification notification = new
NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(songName).build();
notification.contentView = simpleContentView;
我得到了 timeWhenPaused
的时间。
long timeWhenPaused = myChronometer.getBase() - SystemClock.elapsedRealtime();
然后创建计时器
chronometer
。notification.contentView.setChronometer(R.id.chronometer_recorder
, (SystemClock.elapsedRealtime() + timeWhenPaused)
, null
, true
);
从零开始