Получить список текущих открытых приложений в Котлин

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