简体   繁体   中英

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. 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.

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)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM