get list of current open apps in kotlin code example
Example: get list of current open apps in kotlin
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.
}
}