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

The Archive Base Latest Questions

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

Why i am getting this error when i use this code in the asynctask

  • 0

Why i am getting this error when i use this code in the asynctask even i am using runOnUiThread() this is the code i am using ( i am using fragments ).

private class GmailXMPP_AfterLogin extends AsyncTask<AfterLogging, Void, Void> {

    private ProgressDialog _dialog;

    @Override
    protected void onPreExecute() {          
        super.onPreExecute();
        _dialog = new ProgressDialog(getActivity());     
        _dialog.setCancelable(false);
        _dialog.setTitle("colors");
        //((ProgressDialog)dialog).setIcon(R.drawable.icon);
        _dialog.setMessage("Your content is loading.. \nPlease wait..");
        _dialog.setIndeterminate(false);         
        _dialog.show();
        //ProgressBar_show();
        Log.i(TAG, " GmailXMPP_AfterLogin onPreExecute" );
    }

    @Override
    protected void onPostExecute(Void feed) {
        //ProgressBar_hide();       
        _dialog.dismiss();
        Log.i(TAG, " GmailXMPP_AfterLogin onPostExecute" );
    }

    @Override
    protected Void doInBackground(AfterLogging... arg0) {

        Log.i(TAG, " GmailXMPP_AfterLogin doInBackground" );
        AfterLogging after = arg0[0];
        final XMPPConnection _connection = after.getConn();
        final String Uname = after.getAcc_Name();

                //synchronized (contactJids) {
        Roster roster = Gtalk_xmpp_client.getRoster();
        String file_name;
        for (RosterEntry entry : roster.getEntries()) {
            if (entry.getType() == ItemType.to || entry.getType() == ItemType.both) {

                boolean yes = Contact_data_source.checkUsername(entry.getUser());
                Log.i(TAG, "Con=" + yes);
                if (!yes) {

                    Bitmap buddy_img = buddyImage(entry, _connection);
                    if (buddy_img != null)
                        file_name = Store(buddy_img);
                    else
                        file_name = "";
                    if (entry.getName() == null)
                        Contact_data_source.createContact( entry.getUser(), entry.getUser(), Uname, file_name, UsedStrings.GoogleAccount );
                    else
                        Contact_data_source.createContact( entry.getName(), entry.getUser(), Uname, file_name, UsedStrings.GoogleAccount );
                } else {
                    Log.i(TAG, "Con=exist");
                }
            }
        }               
        return null;
    }
 }

logcat shows

12-01 11:59:21.549: E/AndroidRuntime(16595): FATAL EXCEPTION: AsyncTask #1
12-01 11:59:21.549: E/AndroidRuntime(16595): java.lang.RuntimeException: An error occured while executing doInBackground()
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.lang.Thread.run(Thread.java:1019)
12-01 11:59:21.549: E/AndroidRuntime(16595): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.os.Handler.<init>(Handler.java:121)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.app.Dialog.<init>(Dialog.java:101)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.app.AlertDialog.<init>(AlertDialog.java:63)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.app.ProgressDialog.<init>(ProgressDialog.java:80)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.app.ProgressDialog.<init>(ProgressDialog.java:76)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at com.pipemedia.fragments.ChatAccountsFragment$GmailXMPP_AfterLogin.onPreExecute(ChatAccountsFragment.java:372)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.os.AsyncTask.execute(AsyncTask.java:391)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at com.pipemedia.fragments.ChatAccountsFragment.Gtalk_logInComplete(ChatAccountsFragment.java:435)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at com.pipemedia.xmpp.GmailXmppClient.Login(GmailXmppClient.java:60)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at com.pipemedia.fragments.ChatAccountsFragment$GmailXMPP.doInBackground(ChatAccountsFragment.java:337)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at  com.pipemedia.fragments.ChatAccountsFragment$GmailXMPP.doInBackground(ChatAccountsFragment.java:1)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
12-01 11:59:21.549: E/AndroidRuntime(16595):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
12-01 11:59:21.549: E/AndroidRuntime(16595):    ... 4 more

this is the line creating error

line 372 : progress_dialog = new ProgressDialog(getActivity());
  • 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-15T04:39:16+00:00Added an answer on June 15, 2026 at 4:39 am

    Probablly you called AsyncTask.execute() in a background thread.

    You can only execute AsyncTask in UI thread.

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

Sidebar

Related Questions

i try to use TBXML and getting this error TBXML class method +tbXMLWithURL not
I am getting this error when i use a string array java.lang.NullPointerException The code
I am getting this error in a PHP class... Fatal error: Can't use method
I'm getting the links to the files using this code: private List<String> getFilesList(String path,
I am getting this error when I use this code sub search { my
I am getting this error when I use the Linq expression of var emp
I'm getting this error when I use MarshallingView to marshal my list (java.util.List) of
I am trying to use a function pointer and I am getting this error:
Im trying to use Date Formatters (NSDateFormatter), but I keep getting this error: Program
I am getting this error on code that used to work. I have not

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.