我正在开发一个用户活动跟踪应用程序。即使应用程序处于后台或退出状态,我也需要跟踪用户活动。
我已经开始用户活动跟踪并退出应用程序。一段时间后,我想停止用户活动跟踪。现在该应用程序没有任何实例。我没有任何实例可以停止用户活动跟踪。
从我最近的应用程序中删除应用程序后,所有静态引用都被清除。一切正常。但我不知道如何在应用退出后一段时间停止用户活动跟踪。
/**
* Make the actual update request. This is called from onConnected().
*/
private void continueRequestActivityUpdates() {
/*
* Request updates, using the default detection interval. The
* PendingIntent sends updates to ActivityRecognitionIntentService
*/
getActivityRecognitionClient().requestActivityUpdates(
Constants.DETECTION_INTERVAL_MILLISECONDS,
createRequestPendingIntent());
}
我想知道当我在后台时如何阻止这种情况。因为一旦应用退出,我就没有任何实例可以阻止它。
请帮助我。提前致谢。