Search code examples
androiduniversal-image-loader

Universal Image Loader gets image but output appears blank


I've got an image in a shared folder on DropBox. I've got the Universal Image Loader loaded into my app and I'm trying to pull the image from the shared folder and display it in an image view. Everything seems to be working, except when it comes to displaying the image all I get is a white screen.

String fileURL = "https://www.dropbox.com/s/(obfuscated)/stripad.jpg";

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(config);

ImageView imageview = (ImageView)findViewById(R.id.adtest1);
DisplayImageOptions options = new DisplayImageOptions.Builder()
        .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
        .cacheInMemory(true)
        .bitmapConfig(Bitmap.Config.RGB_565)
        .build();
imageLoader.displayImage(fileURL, imageview, options);

My XML is as such:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DropBoxTest">

    <ImageView
        android:id="@+id/adtest1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        />

</RelativeLayout>

I can't figure out what's wrong. I'm not getting any errors and the LogCat is empty. I've tried both .PNG and .JPG images and I get the same behavior with both types. I can manually navigate out to the fileURL in a browser and see the image with no problem.


Solution

  • You're supplying a wrong url. What you have is not a direct url to the image, dropbox redirects it to a webpage, so it cannot be decoded as an image. I extracted one of the alternative urls from that page and it worked. Try this:

    https://photos-5.dropbox.com/t/2/AABK87ma_5R3iq0CcE0KJD-UzdevZ6-khx0Qr6_msAPFPw/12/442547683/jpeg/32x32/3/1527224400/0/2/stripteaserad.jpg/EPmz9MgDGPUQIAcoBw/h_Pb1ngZ6KBY9w5bqERmy6ouX--cPSFaExdsGsqJiQ8?dl=0&size=2048x1536&size_mode=3

    You need to find a proper hosting service.

    P.S. Your URL is a risky click of the day btw