Picasso does not load image from local file

I have a view that usually gets an image of it from the internet. But when the online image is not available (for example, in airplane mode), the image can be loaded from the local file system if available. But Picasso doesn't load the image. I use logging to keep track of my progress, so I know it's all done to call the picasso. How do I print the error if it exists? Or better yet, how do I fix the problem? Again everything works fine when the same code works with the server url.

Here is the path to the local file:

 /storage/emulated/0/DCIM/Camera/20140922_162920-1.jpg

      

Here is the code

private void addBkgFromLocalCache(String uriStr) {
    if (null != uriStr) {
        Log.i(TAG, "bkg uirstring is not null: " + uriStr);
        Uri uri = Uri.parse(uriStr);
        Log.i(TAG, "bkg uri is : " + uri);

        Picasso.with(this).load(uri).into(new Target() {

            @Override
            public void onBitmapFailed(Drawable arg0) {
            }

            @Override
            public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1) {
                Log.i(TAG, "Loading bkg from local: call from inside picasso");
                setActivityBackground(bitmap);
            }

            @Override
            public void onPrepareLoad(Drawable arg0) {
            }
        });
    }
}

      

Also I get the same problem with no image if I use File f = new File(uriStr)

Uri instead.

+3


source to share





All Articles