【问题标题】:getApplicationIcon() from packageManager not returning Gallery app icon来自 packageManager 的 getApplicationIcon() 不返回图库应用程序图标
【发布时间】:2022-06-10 17:42:01
【问题描述】:

尝试使用packageManager 在我的三星手机上获取默认图库应用程序图标会返回文件应用程序图标。如何获取图库应用的图标?

val intent = Intent(Intent.ACTION_GET_CONTENT, null)
intent.setType("image/*")
val appInfo = LocalContext.current.packageManager.resolveActivity(intent, MATCH_DEFAULT_ONLY) // Also tried MATCH_ALL
val icon = appInfo?.loadIcon(LocalContext.current.packageManager)

它返回这个图标,包名com.google.android.documentsui

【问题讨论】:

    标签: android android-intent android-jetpack-compose android-gallery android-package-managers


    【解决方案1】:

    我需要改用ACTION_PICK Intent。现在可以了。

    val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-27
      • 2013-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多