File tree Expand file tree Collapse file tree
app/src/main/java/ai/elimu/kukariri/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ### Issue Number
2+ <!-- Which issue does this PR address? E.g. "Resolves #123" -->
3+ * Resolves #
4+
5+ ### Purpose
6+ <!-- What is the purpose of this PR? Why is it needed? -->
7+ *
8+
9+ ### Technical Details
10+ <!-- Are there any key aspects of the implementation to highlight? -->
11+ *
12+
13+ ### Testing Instructions
14+ <!-- How can the reviewer verify the functionality or fix introduced by this PR? Please provide steps. -->
15+ *
16+
17+ ### Regression Testing
18+ <!-- Have you verified that previously developed software still performs as expected? -->
19+ - [ ] I have tested that the changes in this pull request didn't break any existing functionality
20+
21+ ### Screenshots
22+ <!-- If this PR affects the UI, please include before/after screenshots demonstrating the change(s). -->
23+ *
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ import android.os.IBinder
88import android.util.Log
99
1010class ScreenOnService : Service () {
11+
12+ private lateinit var screenOnReceiver: ScreenOnReceiver
13+
1114 override fun onBind (intent : Intent ): IBinder ? {
1215 return null
1316 }
@@ -16,9 +19,18 @@ class ScreenOnService : Service() {
1619 Log .i(javaClass.name, " onStartCommand" )
1720
1821 // Register receiver for detecting when the screen is turned on
19- val screenOnReceiver = ScreenOnReceiver ()
22+ screenOnReceiver = ScreenOnReceiver ()
2023 registerReceiver(screenOnReceiver, IntentFilter (Intent .ACTION_SCREEN_ON ))
2124
2225 return super .onStartCommand(intent, flags, startId)
2326 }
27+
28+ override fun onDestroy () {
29+ super .onDestroy()
30+ try {
31+ unregisterReceiver(screenOnReceiver)
32+ } catch (e: Exception ) {
33+ Log .e(" ScreenOnService" , " Error unregistering receiver" , e)
34+ }
35+ }
2436}
You can’t perform that action at this time.
0 commit comments