-2

Ii am trying to download an image from web and dispaly it in an image view. the problem is that nothing displays on the screen. I am using the code below. Thank you!

package com.example.citiestoremember;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;

public class DisplayImage extends Activity {
ImageView img;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_city);
      Intent theIntent = getIntent();

    String urlImage = theIntent.getStringExtra("urlImage");
          try {
              img = (ImageView) findViewById(R.id.urlImage);
              Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new     URL(urlImage).getContent());
              img.setImageBitmap(bitmap); 
            } catch (MalformedURLException e) {
              e.printStackTrace();
            } catch (IOException e) {
              e.printStackTrace();
            }
}

}

1

1 Answer 1

1

ImageLoader is not an Universal ImageLoader. Android is providing AQuery for Image Loading.

You will find aQuery jar file from below link:

http://code.google.com/p/android-query/

private AQuery androidAQuery; androidAQuery = new AQuery(getActivity());

androidAQuery.id(your imageview).image(your image value, true, true,default icon(optional));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.