Android Volley : ImageRequest deprecated
Asked Answered
C

3

10

I'm on Android Studio version 1.4. I'm using the Android Volley library (I use the mcxiaoke mirror here). But the ImageRequest is deprecated. The code still works but deprecated. Has anyone found an alternative for this?

I've search for this issue in Google but didn't find any solution.

Screenshot 1

Cineaste answered 22/10, 2015 at 1:12 Comment(0)
A
27

I think the class is not deprecated but the constructor that you are using is deprecated.

use this constructor instead of this one

Usage example :

ImageRequest request = new ImageRequest(
                             url, myResponseListener, maxWidth,
                             maxHeight, scaleType, Config.RGB_565, myErrorListener);
Arp answered 22/10, 2015 at 1:30 Comment(1)
thank you very much for pointing that out. Sorry for my noobness, very new to android.Cineaste
S
3
 button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final ImageRequest imageRequest=new ImageRequest (url, new Response.Listener<Bitmap>() {
                @Override
                public void onResponse(Bitmap response) {
                    imageView.setImageBitmap(response);

                }
            },0,0, ImageView.ScaleType.CENTER_CROP,null, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(MainActivity.this,"Some Thing Goes Wrong",Toast.LENGTH_SHORT).show();
                    error.printStackTrace();

                }
            });emphasized text
Stave answered 13/11, 2016 at 5:59 Comment(0)
C
1

I've used Square's Picaso library as an alternative. It works well; you can check it out at http://square.github.io/picasso/.

Capello answered 22/10, 2015 at 1:22 Comment(2)
Thank you for your answer. It looks interesting, sure i will try it later.Cineaste
Although picasso is great, i suggest to just use volley for everything, stringrequest, jsonrequest, imagerequest. So you can benefit from lower app weight by using less libraries.Audible

© 2022 - 2024 — McMap. All rights reserved.