+
+ // Start the realtime monitoring service if it is enabled.
+ if (realtimeMonitoring) {
+ // Get a handle for the activity manager.
+ val activityManager: ActivityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
+
+ // Get a list of the running service info. The deprecated `getRunningServices()` now only returns services stared by Privacy Cell, but that is all we want to know anyway.
+ val runningServiceInfoList: List<ActivityManager.RunningServiceInfo> = activityManager.getRunningServices(1)
+
+ // Start the service if it is not already running.
+ if (runningServiceInfoList.isEmpty()) {
+ startService(Intent(this, RealtimeMonitoringService::class.java))
+ }
+ }