get list of current open apps in kotlin
snippet in kotlin

get list of current open apps in kotlin

user9419

val am = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val runningAppProcessInfo = am.runningAppProcesses
// detect an app
for (i in runningAppProcessInfo.indices) {
         if (runningAppProcessInfo[i].processName == "com.the.app.you.are.looking.for") {
                    // Do your stuff here.
         }
}