[英]How to get and list all the installed/available navigations apps along with their icons in Android?
As the subject states, I'm looking for a way to get and list all the available navigations apps installed in the Android device along with their respective icons.正如主题所述,我正在寻找一种方法来获取并列出 Android 设备中安装的所有可用导航应用程序及其各自的图标。 Let's say the devices has Google Maps and Waze, I want to get all the info of these apps like their name, icon and package in order to open them from code.
假设这些设备有 Google Maps 和 Waze,我想获取这些应用程序的所有信息,例如它们的名称、图标和 package,以便从代码中打开它们。
You can try this:你可以试试这个:
val packageManager: PackageManager = viewLayer.activity.packageManager
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0"))
val resolvedInfoList: List<ResolveInfo> = packageManager.queryIntentActivities(
intent,
PackageManager.MATCH_DEFAULT_ONLY
)
for (resolvedInfo in resolvedInfoList) {
val packageName: String = resolvedInfo.activityInfo.applicationInfo.packageName
val appName: String = resolvedInfo.activityInfo.applicationInfo.loadLabel(packageManager).toString()
val launcherIcon: Drawable = resolvedInfo.activityInfo.applicationInfo.loadIcon(packageManager)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.