Newer
Older
OverlayMultiCounter / app / src / main / kotlin / jackall / overlaymulticounter / utils / ServiceUtil.kt
MatsumotoKeiju on 10 Nov 2017 692 bytes [add] Activation of service
package jackall.overlaymulticounter.utils

import android.app.ActivityManager
import android.content.Context
import jackall.overlaymulticounter.service.MainService

/**
 * Created by matsumoto_k on 2017/11/10.
 */
class ServiceUtil {
    companion object {
        fun isMainServiceRunning(context: Context): Boolean {
            val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
            for (serviceInfo in manager.getRunningServices(Integer.MAX_VALUE)) {
                if (MainService::class.java.getName() == serviceInfo.service.className) {
                    return true
                }
            }
            return false
        }
    }
}