Handle missing intent extras in TimerService
This might fix an error I was seeing on production in the Play store.
This commit is contained in:
parent
6316e99e6e
commit
9dd929b177
|
@ -25,15 +25,15 @@ class TimerService() : Service() {
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
vibrate = intent!!.extras!!.getBoolean("vibrate")
|
vibrate = intent?.extras?.getBoolean("vibrate") == true
|
||||||
sound = intent.extras?.getString("sound")
|
sound = intent?.extras?.getString("sound")
|
||||||
manager?.cancel(NOTIFICATION_ID_DONE)
|
manager?.cancel(NOTIFICATION_ID_DONE)
|
||||||
applicationContext.stopService(Intent(applicationContext, AlarmService::class.java))
|
applicationContext.stopService(Intent(applicationContext, AlarmService::class.java))
|
||||||
if (intent.action == "add") {
|
if (intent?.action == "add") {
|
||||||
endMs = currentMs.toInt().plus(60000)
|
endMs = currentMs.toInt().plus(60000)
|
||||||
applicationContext.stopService(Intent(applicationContext, AlarmService::class.java))
|
applicationContext.stopService(Intent(applicationContext, AlarmService::class.java))
|
||||||
} else {
|
} else {
|
||||||
endMs = intent.extras!!.getInt("milliseconds")
|
endMs = intent?.extras!!.getInt("milliseconds")
|
||||||
}
|
}
|
||||||
Log.d("TimerService", "endMs=$endMs,currentMs=$currentMs,vibrate=$vibrate,sound=$sound")
|
Log.d("TimerService", "endMs=$endMs,currentMs=$currentMs,vibrate=$vibrate,sound=$sound")
|
||||||
manager = getManager(applicationContext)
|
manager = getManager(applicationContext)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user