+
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
+ // Run the default commands.
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+
+ // Only process the results if they exist (this method is triggered when a dialog is presented the first time for an app, but no grant results are included)
+ // and the result is for the notification permission.
+ if (grantResults.isNotEmpty() && (requestCode == PrivacyCellActivity.NOTIFICATION_PERMISSION_REQUEST_CODE)) {
+ // Check to see if the notification permission was granted. If the dialog was canceled the grant result will be empty.
+ if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The notification permission was granted.
+ // Start the realtime monitoring service.
+ startService(Intent(this, RealtimeMonitoringService::class.java))
+ }
+ }
+ }
+}