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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:16:10+00:00 2026-06-14T16:16:10+00:00

Everywhere I’ve seen, they have used Threading with onClick. Now i am kind of

  • 0

Everywhere I’ve seen, they have used Threading with onClick. Now i am kind of forced to use Threading as i can not perform a networking operation on its main thread as documentation says. So how would i put The threading on a button that i have coded something like this?

public void firstbutton(View view) 
{
//some code
}

Thanks for the help!

EDIT:

        public void firstbutton(View view) 
    {
        InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        EditText editText = (EditText)findViewById(R.id.editText1);
        inputMgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);

        EditText idnumber=(EditText)findViewById(R.id.editText1);
        String idnumber2= idnumber.getText().toString();
        int i = Integer.parseInt(editText.getText().toString());
        idnum=i;
        setContentView(R.layout.viewer);
        Context context = view.getContext();
        Drawable image = ImageOperations(context, WEB ADDRESS HIDDEN FOR PRIVACY"+idnumber2);
        ImageView icon = new ImageView(context);
        icon = (ImageView)findViewById(R.id.imageView1);
        icon.setImageDrawable(image);
};


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

public Object fetch(String address) throws MalformedURLException,IOException
{
URL url = new URL(address);
Object content = url.getContent();
return content;
}
  • 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-06-14T16:16:12+00:00Added an answer on June 14, 2026 at 4:16 pm

    It depends on what you want to achieve.

    If you just want to start a new thread for your networking stuff, you can use the Thread method like this:

    public void firstbutton(View view) 
    {
        new Thread() {
            @Override
            public void run() {
                // Do your network stuff
            }
        }.start();
    }
    

    If you need to update the UI once the network operation is done, AsyncTask is probably a better choice:

        new AsyncTask<Void,Void,ResultType>() {
            @Override
            protected ResultType doInBackground(Void... params) {
                // Do network stuff
                return someResult;
            }
    
            protected void onPostExecute(ResultType result) {
                // Update UI with your result
            };
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everywhere I have seen people talking about storing passwords in a database, they have
I have been looking everywhere but could not find a tutorial for this. I
Everywhere is said that a Java identifier can start with all characters (but not
I've looked everywhere and so far have not found a non-jQuery js to handle
I have checked everywhere looking for a solution to this, and have not been
everywhere they say what IBAction is but do not explain what the whole declaration
I have searched basically everywhere I could think of and can't find anyone with
I keep reading everywhere that CSS is not case sensitive, but I have this
Been searching everywhere and can't find a way to do this. I have a
I have read everywhere that unsigned Java applets are not allowed to make network

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.