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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:16:48+00:00 2026-05-19T22:16:48+00:00

in my application, I have a class for UI stuff, the name of which

  • 0

in my application, I have a class for UI stuff, the name of which is “SettingActivity”.

Then for doing some jobs in background, I bind this UI class(SettingActivity) to a Service.
There are two predefined methods in that Service(defined in .aidl file), one is startTask(), the other one is stopTask().

Within startTask(), I made a call to an AsyncTask. But when I checked the name of the Looper of this AsyncTask. It is “main”. In my opinion, an AsyncTask should start an another Thread other than the main Thread.

So does somebody know why this happens?

The codes are as follows:

@Override
    protected void onPreExecute() {
        super.onPreExecute();
        Log.d(TAG, "onPreExecute "+Looper.myLooper().getThread().getName());
    }

Then I will get main as the output.

  • 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-19T22:16:48+00:00Added an answer on May 19, 2026 at 10:16 pm

    An AsyncTask has several parts that you can override: a doInBackground method that does, in fact, run on a separate thread, and three methods—onPreExecute, onProgressUpdate, and onPostExecute—that run on the UI thread. (The default implementation of these methods do nothing and onProgressUpdate only runs if you call publishProgress, usually from within doInBackground.) The purpose of onPostExecute is to publish results (such as updating the view hierarchy, or setting text in a text view) that must be done on the UI thread. It also can post progress updates. In order for this to all work properly, the AsyncTask must be created, and the execute method called, on the UI thread.

    You must not call UI actions from within doInBackground — doing so will crash your application.

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

Sidebar

Related Questions

In my application I have a class which has properties of user-defined types like
in my zf application i have base model class Application_Model, which connects to db
In my console application have an abstract Factory class Listener which contains code for
I have a class called HeaderView which I use all over my application: public
I have a Dynamic Data application to which I have added a class for
I'm developing an application on the Android system which involves parsing some xml stuff.
I have a simple object like this public class Test { public string Name
We have an Yii-based PHP application which does some generic actions (like Share with
In a client application I have a DBIx::Class model 'Todo' that can be linked
In my application I have a PacketList class and Packet class. I'd like to

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.