0

我需要记录用户在我的应用程序页面上花费的时间。

我希望时间是小时:分钟:秒。

使用它我可以跟踪用户活动。我做了一些研究,但没有发现任何有用的东西。

有没有办法跟踪用户在页面上花费的时间?

4

1 回答 1

2

使用秒表

Stopwatch timer;

protected override void OnAppearing()
{
  timer = new Stopwatch();
  timer.Start();
}

protected override void OnDisappearing()
{
  timer.Stop();
  TimeSpan ts = timer.Elapsed;

  string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}",
            ts.Hours, ts.Minutes, ts.Seconds);
}
于 2020-08-18T16:41:50.427 回答