I want to create a dialog which would let users to select either camera or gallery to pick an image from. Each item in the dialog needs an icon and an image. How can I get those for the default camera and gallery?
Update
I'm currently getting it like this
val galleryIntent = Intent(Intent.ACTION_GET_CONTENT).apply {
setType("image/*")
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/jpeg", "image/png"))
}
val galleryResInfo = packageManager.queryIntentActivities(galleryIntent, 0)[0]
Then in the dialog recycler view holder I can get the icon and name like this
val packageManager = holder.appName.context.packageManager
holder.appIcon.setImageDrawable(app.resolveInfo.loadIcon(packageManager))
holder.appName.setText(app.resolveInfo.loadLabel(packageManager))
Aren't there a better solution?