UIL doesn't support scheme(protocol) by default You should implement this support yourself
Asked Answered
C

2

22

Hello I am capturing image from camera and save it into SDCARD and loading via Universal Image Loader but every time i get an error like

       09-20 14:38:22.617: E/ImageLoader(16626): 
      UIL doesn't support scheme(protocol) by default [/mnt/sdcard/temp_photobooth.png]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))



     imgLoader.displayImage(Environment
                        .getExternalStorageDirectory().toString()
                        + File.separator + Const.TEMP_FILE, choosen_image);

can anybody help me what should i have to do for it?

Clark answered 20/9, 2013 at 9:12 Comment(0)
S
41

If you are loading image from SDCARD you should prefix the path with file:///.

String imageUri = "http://example.com/image.png"; // from Web
String imageUri = "file:///mnt/sdcard/image.png"; // from SD card
String imageUri = "content://media/external/audio/albumart/13"; // from content provider
String imageUri = "assets://image.png"; // from assets
String imageUri = "drawable://" + R.drawable.image; // from drawables (only images, non-9patch)

So you have to write like this:

imgLoader.displayImage("file:///"+Environment
    .getExternalStorageDirectory().toString() + File.separator + Const.TEMP_FILE, choosen_image);
Stoichiometric answered 20/9, 2013 at 9:16 Comment(3)
can UIL load images from internal storage ? When im trying to context.getFilesDir()+"/"+"image.jpg" i have same error...Hypoploid
@Hypoploid try to put "file:///" + context.getFilesDir() +"/"+"image.jpg"Stoichiometric
@Siddhpura Amit Great answerExtract
S
0
lateinit var imageLoader:ImageLoader

in onCreate

val config =
        ImageLoaderConfiguration.Builder(mContext)
            .threadPoolSize(5)
            .threadPriority(Thread.MIN_PRIORITY + 2)
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
            .build()

    imageLoader = ImageLoader.getInstance()
    imageLoader.init(config);

and for use:for example in recycler view bind:

var options : DisplayImageOptions?
val strFileName :String = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()+"/FolderName/"+"filename.jpg"
        val imgFile = File(strFileName)

        if(strFileName!="null" && imgFile.exists()) {
            options = DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.ic_logo_white)
                .showImageForEmptyUri(R.drawable.ic_logo_white)
                .showImageOnFail(R.drawable.ic_logo_white)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .build()
            if (strFileName.contains("http")) {
                imageLoader.displayImage(
                    strFileName,
                    view.imageView,
                    options
                )
            } else {
                imageLoader.displayImage("file:///"+strFileName, view.imageView)
            }
        }
Southernly answered 3/1, 2020 at 17:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.