Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7413059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:38:14+00:00 2026-05-29T06:38:14+00:00

When loading an image from the web I am getting a black screen. I

  • 0

When loading an image from the web I am getting a black screen.

I took the page from the web turned it in to a canvas and then set it to the ImageView.

Now when I load it I am getting a black screen in the image.

Activity’s code:

public class ImageActivity extends Activity {

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

        ImageView i = (ImageView) findViewById(R.id.imageView1);

        try {
            String url = "http://www.rotoworld.com/images/headshots/NBA/1372.jpg";
            Drawable image = ImageOperations(this, url);
            i.setImageDrawable(image);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        i.setMinimumWidth(22);
        i.setMinimumHeight(22);

        i.setMaxWidth(22);
        i.setMaxHeight(22);

    }

    private Drawable ImageOperations(Context ctx, String url) {
        try {
            InputStream is = (InputStream) this.fetch(url);
            Drawable d = Drawable.createFromStream(is, "src");
            return d;
        } catch (MalformedURLException e) {
            return null;
        } catch (IOException e) {
            return null;
        }
    }

    public Object fetch(String address) throws MalformedURLException, IOException {

        URL url = new URL(address);
        Object content = url.getContent();
        return content;
    }

}

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_launcher" />

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:38:16+00:00Added an answer on May 29, 2026 at 6:38 am

    The usual reason for getting a black screen when opening an activity in android is that it takes to long to create the activity.

    I think you should put the fetching of your image in a AsyncTask or similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading an image file from a web server, and then saving it to
Im loading an image from a SQL CE db and then trying to load
I'm loading HTML-formatted content into my app from a web service, then plugging that
I'm getting image from the web when the image size is large i'm getting
I am loading a image from the web to the local android phone. The
I'm loading an image from a file, and I want to know how to
I was loading a Bitmap Image from a File. When I tried to save
So I'm loading images from a web service, but the size of the images
I need to send an image (as a downloadable file) from an ASP web
I am loading files that are downloaded from the web in a UIWebView (HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.