kill other apps in kotlin
snippet in kotlin

kill other apps in kotlin

user1155

// add this permission to AndroidManifest.xml
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
  
//and use this code to kill the process
  
val am = getSystemService(Activity.ACTIVITY_SERVICE) as ActivityManager
am.killBackgroundProcesses(packageName)