I am working on app in which i have to free up some memory from ram.
private fun clearMemory(){
try {
val mActivityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
var packs = context.packageManager.getInstalledPackages(PackageManager.GET_META_DATA)
for (i in 0 until packs.size){
var pkgInfo = packs[i]
mActivityManager.killBackgroundProcesses(pkgInfo.applicationInfo.loadLabel(context.packageManager).toString())
}
}catch (ex: Exception){
ex.printStackTrace()
}
}
Above is the code i am using but i think it cannot perform the required operation.