private fun currentProcessName(context: Context): String {
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (process in manager.runningAppProcesses) {
if (process.pid == Process.myPid()) {
return process.processName
}
}
return ""
}
通过context.getSystemServie 来获取管理对象遍历app进程来获取