CodexBloom - Programming Q&A Platform

ImageView not displaying bitmap loaded from File in Android 14

πŸ‘€ Views: 26 πŸ’¬ Answers: 1 πŸ“… Created: 2025-08-29
android bitmap imageview permissions kotlin

I'm confused about I've hit a wall trying to I've looked through the documentation and I'm still confused about Quick question that's been bugging me - I'm running into an scenario where an `ImageView` fails to display a bitmap that I load from a file... I am using Android 14 and the bitmap is being loaded from a local file in the external storage. I've ensured that I have the necessary permissions set in the manifest and I'm requesting runtime permissions correctly. Here's the code snippet I am using to load the bitmap: ```kotlin val imageView: ImageView = findViewById(R.id.myImageView) val filePath = Environment.getExternalStorageDirectory().absolutePath + "/myImage.png" try { val bitmap = BitmapFactory.decodeFile(filePath) imageView.setImageBitmap(bitmap) } catch (e: Exception) { Log.e("ImageLoad", "Failed to load image: ${e.message}") } ``` I am receiving a `Bitmap is not supported` behavior in my logs, but the file definitely exists and is accessible. I've checked the file path and added permission checks for storage access, but still no luck. I've even tried using `ContentResolver` to open the file, but that didn't work either. Here’s how I’m requesting the permissions: ```kotlin if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), REQUEST_CODE) } else { // Load the image } ``` Could anyone suggest what might be going wrong? Is there a specific way to handle bitmap loading in Android 14 that differs from previous versions? Any insights would be appreciated! I'm working on a web app that needs to handle this. This is part of a larger application I'm building. Am I missing something obvious? I'm using Kotlin 3.11 in this project. Has anyone dealt with something similar? I'm coming from a different tech stack and learning Kotlin. Is this even possible?