0

i seen this, and made how they say. my app loads and shows .jpg, but don't show .png. He shows empty screen. (tested on versions 4.1 and 4.2)

    if (isOnline()) {
            new DownloadImageTask((ImageView) findViewById(R.id.imageViewSA))
                    .execute(img);
        } 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 java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);

    }
Community
  • 1
  • 1
Pavel K
  • 73
  • 9
  • You can google and try Picasso library. It's good! – BNK Oct 05 '15 at 00:55
  • What is the exact problem are you facing? your code seems fine! – Muhammad Babar Oct 05 '15 at 07:32
  • @MuhammadBabar my app loads and shows files ".jpg", but DON'T SHOW files ".png". when i try to load file .png my imageview is empty(white area). Now i will use [inuversal image laoder](http://javatechig.com/android/universal-image-loader-library-in-android) or picasso, and i hope that they will work – Pavel K Oct 05 '15 at 08:32
  • Is your png is opening perfect in imageviewer or browser? – Muhammad Babar Oct 05 '15 at 09:54

1 Answers1

0

you can use universal image loader library instead, so easy to integrate in your code, you can display images from URL to imageView like this

imageLoader.displayImage(url, imageView);

here's a good example of using UIL

and the library

good luck ;)

Sadik anass
  • 282
  • 4
  • 9
  • Thank you! [Universal Image Loader Library In Android](http://javatechig.com/android/universal-image-loader-library-in-android) very simple instrument! – Pavel K Oct 05 '15 at 09:38