📜  在 kotlin 代码示例中获取当前打开的应用程序列表

📅  最后修改于: 2022-03-11 14:53:32.728000             🧑  作者: Mango

代码示例1
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.
         }
}