From c37b888b563b2bcc719ef00391e60129e325f33e Mon Sep 17 00:00:00 2001 From: Jonas L Date: Thu, 14 Feb 2019 12:42:54 +0100 Subject: [PATCH] Improve foreground app detection --- .../android/foregroundapp/LollipopForegroundAppHelper.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/timelimit/android/integration/platform/android/foregroundapp/LollipopForegroundAppHelper.kt b/app/src/main/java/io/timelimit/android/integration/platform/android/foregroundapp/LollipopForegroundAppHelper.kt index ce422e4..431408d 100644 --- a/app/src/main/java/io/timelimit/android/integration/platform/android/foregroundapp/LollipopForegroundAppHelper.kt +++ b/app/src/main/java/io/timelimit/android/integration/platform/android/foregroundapp/LollipopForegroundAppHelper.kt @@ -64,7 +64,9 @@ class LollipopForegroundAppHelper(private val context: Context) : ForegroundAppH // note: when the duration is too small, Android returns no data // due to that, 1 second more than required is queried // which seems to provide all data - lastQueryTime - 1000 + // update: with 1 second, some App switching events were missed + // it seems to always work with 1.5 seconds + lastQueryTime - 1500 } usageStatsManager.queryEvents(queryStartTime, now)?.let { usageEvents ->