AutoStartReceiver refactor
This commit is contained in:
parent
533433afd8
commit
416f5b7cab
3 changed files with 20 additions and 21 deletions
|
@ -1,21 +0,0 @@
|
|||
package info.nightscout.androidaps.receivers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService;
|
||||
|
||||
public class AutoStartReceiver extends BroadcastReceiver {
|
||||
public AutoStartReceiver() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
context.startForegroundService(new Intent(context, DummyService.class));
|
||||
else
|
||||
context.startService(new Intent(context, DummyService.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
|
||||
|
||||
class AutoStartReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
context.startForegroundService(Intent(context, DummyService::class.java))
|
||||
else
|
||||
context.startService(Intent(context, DummyService::class.java))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ import info.nightscout.androidaps.logging.LTag
|
|||
import info.nightscout.androidaps.services.DataService
|
||||
import javax.inject.Inject
|
||||
|
||||
// We are not ready to switch to JobScheduler
|
||||
@Suppress("DEPRECATION")
|
||||
open class DataReceiver : WakefulBroadcastReceiver() {
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
|
|
Loading…
Reference in a new issue