kopia lustrzana https://github.com/ge0rg/aprsdroid
Service: do not crash on service restart after reboot
rodzic
93059b2426
commit
0cc40f7f10
|
@ -1,6 +1,7 @@
|
|||
package org.aprsdroid.app
|
||||
|
||||
import android.content.{BroadcastReceiver, Context, Intent}
|
||||
import android.os.Build
|
||||
|
||||
class SystemEventReceiver extends BroadcastReceiver {
|
||||
val TAG = "APRSdroid.SystemEventReceiver"
|
||||
|
@ -8,7 +9,12 @@ class SystemEventReceiver extends BroadcastReceiver {
|
|||
override def onReceive(ctx : Context, i : Intent) {
|
||||
android.util.Log.d(TAG, "onReceive: " + i)
|
||||
val prefs = new PrefsWrapper(ctx)
|
||||
if (prefs.getBoolean("service_running", false))
|
||||
ctx.startService(AprsService.intent(ctx, AprsService.SERVICE))
|
||||
if (prefs.getBoolean("service_running", false)) {
|
||||
val i = AprsService.intent(ctx, AprsService.SERVICE)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
ctx.startForegroundService(i)
|
||||
else
|
||||
ctx.startService(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue