java – Loading png via url into an existing imageview


You just need to load the png image via the url into the existing imageview .

I tried, as they said here . .jpg pictures perfectly load and display, but does not want to display the .png format, it turns out a blank screen (tested on versions 4.1 and 4.2).

Why is this happening and how to fix it?

if (isOnline()) {
        new DownloadImageTask((ImageView) findViewById(
    } else {
        tv_info.setText("Включите интернет для загрузки");


private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new;
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
        return mIcon11;

    protected void onPostExecute(Bitmap result) {



Use Picasso , it is the most simple, code-efficient and stable.

In the dependencies section (build.gradle) add the library

compile 'com.squareup.picasso:picasso:2.5.2'

Then, in your code, import:

import com.squareup.picasso.Picasso;

and use

ImageView shopLogo = (ImageView) findViewById(;

For the picture, by default, there is .placeholder, and for the picture, if there is a loading error, there is .error

Scroll to Top