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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:39:59+00:00 2026-06-16T06:39:59+00:00

All: I am studying code that has a handler that is declared and instantiated

  • 0

All:

I am studying code that has a handler that is declared and instantiated along with other instance variables:

public class SomeActivity extends Activity {
    Handler handler = new Handler();  // What thread is this taking place on?
    // rest of class omitted
}

so is it being instantiated on the UI thread? I hope so, because it is used to post a Runnable to a ProgressBar, and my understanding is that the ProgressBar should only be manipulated on the UI Thread.

The Android docs say that something created in onCreate() is:

An application’s activities run on the application’s UI thread. Once
the UI is instantiated, for example in the activity’s onCreate()
method, then all interactions with the UI must run in the UI thread.”

but this is happening before onCreate().

Thanks for any info,

Michael

  • 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-16T06:40:01+00:00Added an answer on June 16, 2026 at 6:40 am

    so is it being instantiated on the UI thread?

    Yes. A Handler will exist in the Thread where it is created. You are creating yours on the main / UI Thread, so it can access UI elements.

    but this is happening before onCreate().

    This won’t effect which Thread the Handler runs on.

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

Sidebar

Related Questions

All, I am studying some sample code given in my web dev class as
I recently start studying JAVA, and I find this code: public class Dublicate{ public
Studying some code from a codeigniter tut, the following preg_match pattern has me baffled:
all I am studying node_redis, in examples/simple.js, there is the following code: 1 client.hset(hash
I've been studying the GCC source code and I noticed that most (if not
I'm studying this heap of code a professor left for the class, a java
i'm studying iOS programming. i wrote code that associated an address. there's so many
Studying Haskell, i'm trying to code a function takeIf that given a condition and
After studying TCP/UDP difference all week, I just can't decide which to use. I
I'm studying UML and I've been reading about use cases. All of the examples

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.