且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使天文钟在后台运行?

更新时间:2023-01-05 14:29:38

感谢您的回复!我曾尝试过这种媒介,但没有成功.实际上,我对代码进行了更好的分析,发现自己正在破坏自己.将计时器设置为开始计时后,便创建了一个新的计时表实例.因此它不占.并要利用它们的更多代码计时手段:

Thanks for the reply! I had tried before this medium but without success. In fact I analyzed my code better and saw that I was sabotaging myself. A new instance of Chronometer was created after setting it to start counting. So it does not accounted for. and taking advantage would have to use their means of more this code timing:

long restartTime = getIntent().getLongExtra(Constantes.TIME, 0) + SystemClock.elapsedRealtime();

这是在将当前的计时器设置为有问题的计时器之前的活动时.

This was when set the current getBase the Chronometer in question the previous Activity.

将Activity命名为以下putExtra()的步骤:

And step for the Activity to be called the following putExtra():

long valueChrono = chronometer.getBase()
                    - SystemClock.elapsedRealtime();

谢谢您,遇到任何问题!

Thank you and sorry for any problems!