package com.hh.hhomc

import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import com.hh.hhomc.keeplive.LocalService
import com.hh.hhomc.keeplive.MyJobService
import com.hh.hhomc.keeplive.RemoteService
import com.hh.hhomc.services.BackgroundService

class BackgroundActivity : Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        setContentView(R.layout.activity_main)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // 8.0
            startForegroundService(Intent(this, LocalService::class.java));
            startForegroundService(Intent(this, RemoteService::class.java));
            startForegroundService(Intent(this, BackgroundService::class.java));
        }else{
            startService(Intent(this, LocalService::class.java))
            startService(Intent(this, RemoteService::class.java))

            startService(Intent(this, BackgroundService::class.java))
        }
        MyJobService.StartJob(this)
    }


    override fun onResume() {
        super.onResume()

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            // 6.0以上解决 Activity使用Theme.NoDisplay style 报 did not call finish() prior to onResume() completing
            finish();
        }

    }
}