Search code examples
androidandroid-imageviewimage-loadingandroid-image

Not Load Images from Web in my application


Hello i use Loading Images for Loading Images. But my images are not load. I work on that and develop one Demo program that is as follows.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    new DownloadImageTask((ImageView) findViewById(R.id.my_image))
            .execute("http://www.morroccomethod.com/components/com_virtuemart/shop_image/category/resized/Raw_Conditioner_500835f701532_175x175.jpg");
}

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

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
        pd = new ProgressDialog(ImageLoadExampleActivity.this);
        pd.show();
    }

    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);
        pd.dismiss();

    }
}

It does not work. But if i change URL of image at that time image is loaded successfully. My question is this perticular url is not loaded in my android application. Please help me to find this. I spend one days on this. Thanks in advance.

-Hardik


Solution

  • After spending 2 days i finally come here to give answer on my own question. The main problem is of file names. I change file names and file location of files and my issue is solve. Thanks all which give me idea.

    One also thing which i come to know that i modify my http:// with https://