Android get image source from https url?

I am trying to get an image from https-url, but it doesn't seem to display and doesn't get the image correctly, but works fine in my browser.

I checked the http url pointing to another image and it works fine.

my code is below:

public Bitmap getContactPhoto(String url) {
        Bitmap pic = null;
        try {
            pic = BitmapFactory
                    .decodeStream((InputStream) new URL(
                            "https://mail.google.com/mail/photos/static/AD34hIjbK2m-Lj333E4nBcCkBC3MYl2tTs0xizuSqUOP3-Jd6DOrpFg1M5HG8jXh0MuPbeFepInZZDu92Dx8ST4b59EbOKmfYTortuuO3P1_Ohyu7b7a3gc")
                            .getContent());
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return pic;

    }

here is the code from the activity class that calls the method above:

private ImageView mContactPhoto;
private ContactDetailsViewHelper mViewHelper;

mContactPhoto = (ImageView) findViewById(R.id.contact_photo);
mViewHelper = new ContactDetailsViewHelper(mContext);
mContactPhoto.setImageBitmap(mViewHelper.getContactPhoto(mDetail.getImageRef()));

ignore mDetail.getImageRef, which passes the true url value, but for this case I tried to hardcode the URL, as you can see from the getContactPhoto method.

thank

+3
source share
1 answer

, GMail cookie, . Incongnito/Private Browsing/InPrivate. .

+1

Source: https://habr.com/ru/post/1774291/


All Articles