0

I'm trying to set an ImageButton image using that images file path like so.

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED & ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)
    {
        ImgButton.setImageURI(Uri.parse(imagePath));

    }
    else
    {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_CODE);

    }

This isnt displaying the image and im not sure why? any help is appreciated.

  • Are you getting any errors? Does it enter the else block? what is image Path? what is the result of Uri.parse(imagePath)? Debugging might help answer some of these questions. – Akin Okegbile Jan 03 '20 at 20:42
  • The code runs without errors. It has permissions so it enters the if block. imagePath in this case is equal to "/storage/emulated/0/Download/download.jpeg" – BasRut10 Jan 03 '20 at 21:14
  • On Android Q. ? What is the size of the jpg file? And its resolution,,? – blackapps Jan 03 '20 at 21:37
  • Yeah its android Q, as for the size, im not sure how to find that out? would its size and resolution have an effect? – BasRut10 Jan 03 '20 at 22:46
  • here's the link that will workif you have the path of file https://stackoverflow.com/a/4182060/8927208 – Khalid Saeed Jan 04 '20 at 07:41

0 Answers0