android check if app is running

Solutions on MaxInterview for android check if app is running by the best coders in the world

showing results for - "android check if app is running"
Magdalena
30 Oct 2016
1private fun isAppRunning() : Boolean {
2        val services = (getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses
3        return services.firstOrNull{it.processName.equals(packageName,true)} != null
4    }