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 } } }