Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load URL image in android wear?

Right now I am using Glide-library to load the image in Android Wear. It doesn't load the image in most of the times. However, it loads image sometimes. Don't know what going wrong in my code.

Note Wear is connected to the device via Bluetooth and I successfully get JSON response of Webservice in Android Wear via Broadcast Receiver from mobile. All data are displayed properly in wear except the images.

Glide.with(mContext)
   .load("http://www.hanamoflorist.ca/images/uploads/Spring5InchesCubeVaseArrangement$45.00.jpg")
      .listener(new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            Log.e("exception in image", "" + e);
            Toast.makeText(mContext, "" + e, Toast.LENGTH_LONG).show();
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            return false;
        }
    }).error(R.drawable.ic_placeholder_image)
        .into(((ItemViewHolder) holder).ivCardImage);
like image 963
Viraj Patel Avatar asked Jan 06 '17 05:01

Viraj Patel


People also ask

How will you load an image into an ImageView from an image URL using Picasso?

Image loading using Picasso is very easy, you can do it like this way Picasso. get(). load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.

Which library do we use to display images from Internet in Android?

Official Google apps are also using Glide. Glide is an Image Loader Library in Android developed by bumptech and is a library that is backed by Google.


1 Answers

I think you should use, DaVinci for image loading in Wearable,

DaVinci.with(context).load("Your Url").into(imageView);

Make sure you use the same playservices version as the library,

You will be able to integrate the same by adding this to your gradle:

wear :

compile ('com.github.florent37:davinci:1.0.3@aar'){
    transitive = true
}

Mobile:

compile ('com.github.florent37:davincidaemon:1.0.3@aar'){
     transitive = true
}

Hope you will get what you want.

like image 63
Deep Patel Avatar answered Oct 29 '22 15:10

Deep Patel