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

  • Home
  • SEARCH
  • 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 6320215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:55:58+00:00 2026-05-24T15:55:58+00:00

Because my app depends much on Network, I wish my app should not hang

  • 0

Because my app depends much on Network, I wish my app should not hang up.
So i tried to use Asyncask

I have a

  1. MainActvity extends Second Activity
  2. AsyncTask as Inner Class in MainActivity
  3. Second Activity

Main Activity and Async Task :

public class MainActivity extends secondActivity implements OnClickListener{
@Override
public void onClick(View arg0) {
    new triggerAsync().execute(str);
}

private class triggerAsync extends AsyncTask<String,String,String>
{
    @Override       
    protected String doInBackground(String... str) {

        try {
             setConnection();
             getID(txtUserName);
             Log.d("Inside Background","string here"+str[0]);
            // postOnWall(str[0]);  
        } catch (Exception e) {
            e.printStackTrace();
        }   
        return null;
    }

    @Override
    protected void onPostExecute(String result) {

        super.onPostExecute(result);
    }}}

Second Activity :

public class SecondActivity extends Activity {


public void setConnection() {
    //My stuffs
}

public void getID(TextView txtUserName) {

    // here i'm calling another function inside package

    if (isSession()) {
        Log.d(TAG, "sessionValid");
        mAsyncRunner.request("me", new IDRequestListener());
    } else {
        // no logged in, so relogin
        Log.d(TAG, "sessionNOTValid, relogin");
        mFacebook.authorize(this, PERMS, new LoginDialogListener());
    } 
}

/////////////// Code continues.....}

What is the error in this code, please help me to solve this
I’m getting below error

08-15 11:01:07.211: WARN/System.err(462): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
08-15 11:01:07.251: WARN/System.err(462):     at android.os.Handler.<init>(Handler.java:121)
08-15 11:01:07.251: WARN/System.err(462):     at android.app.Dialog.<init>(Dialog.java:101)
08-15 11:01:07.271: WARN/System.err(462):     at android.app.Dialog.<init>(Dialog.java:123)
08-15 11:01:07.271: WARN/System.err(462):     at com.facebook.android.FbDialog.<init>(FbDialog.java:63)
08-15 11:01:07.281: WARN/System.err(462):     at com.facebook.android.Facebook.dialog(Facebook.java:622)
08-15 11:01:07.291: WARN/System.err(462):     at com.facebook.android.Facebook.startDialogAuth(Facebook.java:297)
08-15 11:01:07.301: WARN/System.err(462):     at com.facebook.android.Facebook.authorize(Facebook.java:195)
08-15 11:01:07.311: WARN/System.err(462):     at com.facebook.android.Facebook.authorize(Facebook.java:114)
08-15 11:01:07.321: WARN/System.err(462):     at com.singleupdater.FacebookActivity.getID(FacebookActivity.java:61)
08-15 11:01:07.331: WARN/System.err(462):     at com.singleupdater.SingleStausUpdater$postToTwitter.doInBackground(SingleStausUpdater.java:149)
08-15 11:01:07.341: WARN/System.err(462):     at com.singleupdater.SingleStausUpdater$postToTwitter.doInBackground(SingleStausUpdater.java:1)
08-15 11:01:07.351: WARN/System.err(462):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-15 11:01:07.361: WARN/System.err(462):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-15 11:01:07.371: WARN/System.err(462):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-15 11:01:07.371: WARN/System.err(462):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
08-15 11:01:07.391: WARN/System.err(462):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
08-15 11:01:07.391: WARN/System.err(462):     at java.lang.Thread.run(Thread.java:1096)
  • 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-24T15:55:59+00:00Added an answer on May 24, 2026 at 3:55 pm

    It seems that some of your methods – setConnection() or getID(txtUserName) tries to access UI from background thread and fails. Move your UI logic to onPostExecute to be processed on UI thread.

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

Sidebar

Related Questions

From the GAE getting started guide Because the App Engine datastore is not a
i am getting this error failed to execute request because the app-domain could not
I have recently been rewriting some of my iphone app because a couple of
I make call from my app with this code (i use webview because after
I need ImageMagick with my RoR app, because I use rmagick and carrierwave gems
I have a multi module project like this: gwt-app model webapp (depends on gwt-app
I have a backgorund thread that extends AsyncTask and which I use in activity
I am creating a Table View in viewDidAppear, because my app requires it to
Because the data size isn't little that my web app needs to load, it
Note: I am cross-posting this from App Engine group because I got no answers

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.