I'm facing trouble with MiUi SO when I run the following function.
fun getAppsThatCanBeStopped(context: Context): List<String> {
return with(ArrayList<String>()) {
addAll(
context.packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
.filter { (it.flags and ApplicationInfo.FLAG_STOPPED == 0) and (it.flags and ApplicationInfo.FLAG_SYSTEM == 0) }
.map { it.packageName }
)
this@with
}
}
The problem is only with MiUi SO all the apps are returning, The FLAG ApplicationInfo.FLAG_STOPPED it's not being satisfied.
Should return only the apps that aren't stopped and aren't system apps.
Any suggestions?