你好,我有一个应用程序,它会启动一个应用程序,以System.currentTimeMillis
了解您自启动以来使用该应用程序多长时间,它运行良好
但我想要做的是将保存的毫秒添加到当前系统毫秒,因此在加载数据时它将从停止的地方继续。
long starttime = System.currentTimeMillis(), millis;
int seconds, minutes, hours;
final Handler h = new Handler(new Callback()
{
public boolean handleMessage(Message msg)
{
millis = System.currentTimeMillis() - starttime;
seconds = (int) (millis / 1000);
minutes = seconds / 60;
hours = minutes / 60;
seconds = seconds % 60;
minutes = minutes % 60;
playtime.setText(String.format("%d:%02d:%02d", hours, minutes, seconds));
return false;
}
});
class firstTask extends TimerTask
{
@Override
public void run()
{
h.sendEmptyMessage(0);
}
};
Timer timer = new Timer();