【问题标题】:Xamarin Forms: How to capture the time spend on a pageXamarin Forms:如何捕获在页面上花费的时间
【发布时间】:2020-08-18 15:41:33
【问题描述】:

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

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

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

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

【问题讨论】:

  • 在 OnAppearing 和 OnDisappearing 事件中捕获时间戳

标签: xamarin.forms time-tracking


【解决方案1】:

使用Stopwatch

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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-22
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    相关资源
    最近更新 更多