Skip to content

Commit

Permalink
Service being stopped onPause fixed
Browse files Browse the repository at this point in the history
...and also some typos
  • Loading branch information
albertopasqualetto committed Jul 3, 2023
1 parent 6bfbcaf commit 6e14009
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class MainActivity : ComponentActivity() {
super.onResume()
Log.d(TAG, "onResume!")
if (isRunning) {
Log.d(TAG, "onResume: restart service (isRunning)")
val i = Intent(applicationContext, MeterService::class.java)
startForegroundService(i)
}
Expand Down Expand Up @@ -290,7 +291,7 @@ class MainActivity : ComponentActivity() {

val windowSizeClass = if(!LocalInspectionMode.current) calculateWindowSizeClass(this) else WindowSizeClass.calculateFromSize(DpSize(360.dp, 760.dp)) // fallback WindowSizeClass used for preview
if (windowSizeClass.heightSizeClass != WindowHeightSizeClass.Compact) {
Log.d(TAG, "In column arrangement")
Log.d(TAG, "In Column arrangement")
Column(
modifier = Modifier
.fillMaxSize()
Expand All @@ -301,7 +302,7 @@ class MainActivity : ComponentActivity() {
RightOneSecView(rightdb, animatedProgressRight, updateChartOneRight, modifier= Modifier.weight(1f))
}
} else {
Log.d(TAG, "In row arrangement")
Log.d(TAG, "In Row arrangement")
Row(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -409,7 +410,7 @@ class MainActivity : ComponentActivity() {

val windowSizeClass = if(!LocalInspectionMode.current) calculateWindowSizeClass(this) else WindowSizeClass.calculateFromSize(DpSize(360.dp, 760.dp)) // fallback WindowSizeClass used for preview
if (windowSizeClass.heightSizeClass != WindowHeightSizeClass.Compact) {
Log.d(TAG, "In column arrangement")
Log.d(TAG, "In Column arrangement")
Column(
modifier = Modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ class MeterService : Service() {
override fun run() {
Log.d(TAG, "TimerTask: stopSelf")
stopSelf()
timer.cancel()
}
}
timer.schedule(timerTask, 0, 600000) // stop service after 10 minutes of timeout if MainActivity has been paused
timer.schedule(timerTask, 600000) // stop service after 10 minutes of timeout if MainActivity has been paused
}


Expand Down Expand Up @@ -134,7 +135,9 @@ class MeterService : Service() {
}

override fun run() {
super.run()
if (meter == null) Log.d(TAG, "rec: meter is null")
Log.d(TAG, "Starting AudioRecordThread")
isRecording = true
meter?.startRecording()

Expand Down Expand Up @@ -167,6 +170,7 @@ class MeterService : Service() {

override fun run() {
super.run()
Log.d(TAG, "Starting AudioReadThread")
try{
sleep(1000)
} catch (e: InterruptedException) {
Expand Down

0 comments on commit 6e14009

Please sign in to comment.