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 6981935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:13:20+00:00 2026-05-27T18:13:20+00:00

In Android development, I am loading a drawable from a url with this code:

  • 0

In Android development, I am loading a drawable from a url with this code:

public Drawable getImageFromURL(String sURL) {
    Object content = null;
    try {
        URL url = new URL(sURL);
        content = url.getContent();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    InputStream is = (InputStream) content;
    return Drawable.createFromStream(is, "src");
}

But I want to display this ProgressBar while it loads the drawable:

final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        progressBar = ProgressDialog.show(TabMenu.this, getString(R.string.name), getString(R.string.specials));
        progressBar.setIcon(R.drawable.icon_template);

How do I do that? I call getImageFromURL() in the onCreate() methode of the Activity.
Thanks for your help!

  • 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-27T18:13:21+00:00Added an answer on May 27, 2026 at 6:13 pm
    private Handler handler = new Handler() {
    
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            // do something
    
            switch (msg.what){
                case 1:
                   //ALL FUNCTION(S) -----------------------------
                   //-----------------------------------------------------
                   //-----------------------------------------------------
                   p_dialog.dismiss();
                   break;
    
               // if error
               case 0:
                   Toast.makeText(aktiviti.this, "Error", Toast.LENGTH_SHORT).show();
                   p_dialog.dismiss();
                   break;
            }
        }
    };
    

    ON CREATE ———> <—————-

    Button new_button = (Button) findViewById(R.id.new_button);
    
    new_button.setOnClickListener(new OnClickListener() {
    
        public void onClick(View v) {
    
            p_dialog = ProgressDialog.show((activity_name).this, "", "Loading Image...");
    
            new Thread(new Runnable() {
                public void run() {
                    processThread();
                }}).start();
            }
    
            private void processThread() {
                try{
                    handler.sendEmptyMessage(1);
                }
                catch (Exception e){
                    handler.sendEmptyMessage(0);
                }
            }
        }
    });
    

    Good Luck!

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

Sidebar

Related Questions

Hey i recently started android development and encountered a problem when saving/loading data from
In Android development, will Bitmap bmpNormal = BitmapFactory.decodeResource(res, R.drawable.normal); load the bitmap from the
Is there a standard Loading, please wait dialog I can use in Android development,
I'm starting android development from just three days, I have downloaded the SDK and
I am New to Android Development.How to convert the Following string(5/31/2011) in to the
I am new to Android development. I am trying to use the following code
Doing Android development on a Mac and this very new phone I have doesn't
I am newbie to Android development and this webview and webview client is killing
i am new to android development and i am now developing a project. This
Is Android development restrictive in any way like the iPhone , or can you

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.