I have used this code to get all list apps installed from user. But this code can not get all list app installed only get a part. Examle my phone have app Facebook, Messenger, Telegram ... But this code can not get those apps. My code:
private fun getInstalledApps(context: Context): ArrayList<AppInstall> {
val mainIntent = Intent(Intent.ACTION_MAIN, null)
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
val pkgAppsList: List<ResolveInfo> =
context.packageManager.queryIntentActivities(mainIntent, 0)
Log.d("TEST_LIST", pkgAppsList.size.toString())
val res: ArrayList<AppInstall> = ArrayList<AppInstall>()
for (i in pkgAppsList.indices) {
val name =
pkgAppsList[i].activityInfo.applicationInfo.loadLabel(context.packageManager)
.toString()
val drawable =
pkgAppsList[i].activityInfo.applicationInfo.loadIcon(context.packageManager)
val bitmap: Bitmap? = drawableToBitmap(drawable)
val idApp = pkgAppsList[i].activityInfo.packageName
val appInstall = AppInstall(name, bitmap, idApp)
res.add(appInstall)
}
return res
}
Is there any other way to get all the apps installed on the phone ?. Thank you !