android check if app is running or not

www.la‮‬utturi.com
android check if app is running or not
private fun isAppRunning() : Boolean {
    val services = (getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses
    return services.firstOrNull{it.processName.equals(packageName,true)} != null
}
Created Time:2017-08-30 15:20:20  Author:lautturi