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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:44:33+00:00 2026-06-17T11:44:33+00:00

I’m trying to use Progress Dialog with Async task in my Adroid app. But

  • 0

I’m trying to use Progress Dialog with Async task in my Adroid app. But when I run my app this is causing a Fatal Exception. When I used it in another method it worked properly. But when I used it with the method below, it caused an error. I read in other questions that it’s because of the Array, but I don’t know whether it is true.

Here is my Activity codes:

private class TheTask extends AsyncTask<Void, Void, Void>{
  @Override
  protected void onPreExecute() {
    authProgressDialog = ProgressDialog.show(Front9Activity.this, "", "Authenticating...", true, false);
  }
  @Override
  protected Void doInBackground(Void... params) {
    loading();
    return null;
  }
  @Override
  protected void onPostExecute(Void result) {
    if(authProgressDialog.isShowing()) {
      authProgressDialog.dismiss();
    }
    return;
  }
}
public void loading(){
  mode = Integer.parseInt(gametype);
  check = Integer.parseInt(type);
  if(mode == 1) {
    name = name1;
    number = mobile1;
  } else if(mode == 2) {
    name = name2;
    number = mobile2;
  } else if(mode == 3) {
    name = name3;
    number = mobile3;
  } else {
    name = name4;
    number = mobile4;
  }
  if(check == 1){
    data = "Solo";
  } else if(check == 2) {
    data = "GroupScore";
  } else {
    data = "Tournament";
  }
  save = openOrCreateDatabase("clubscores", MODE_PRIVATE,null);
  Cursor c = save.rawQuery("Select *from Courses where VenueName = '"+ courses +"'", null);
  c.moveToFirst();
  ((TextView) findViewById(R.id.front9hole1)).setText(c.getString(c.getColumnIndex("Hole1")));
  ((TextView) findViewById(R.id.front9hole2)).setText(c.getString(c.getColumnIndex("Hole2")));
  ((TextView) findViewById(R.id.front9hole3)).setText(c.getString(c.getColumnIndex("Hole3")));
  ((TextView) findViewById(R.id.front9hole4)).setText(c.getString(c.getColumnIndex("Hole4")));
  ((TextView) findViewById(R.id.front9hole5)).setText(c.getString(c.getColumnIndex("Hole5")));
  ((TextView) findViewById(R.id.front9hole6)).setText(c.getString(c.getColumnIndex("Hole6")));
  ((TextView) findViewById(R.id.front9hole7)).setText(c.getString(c.getColumnIndex("Hole7")));
  ((TextView) findViewById(R.id.front9hole8)).setText(c.getString(c.getColumnIndex("Hole8")));
  ((TextView) findViewById(R.id.front9hole9)).setText(c.getString(c.getColumnIndex("Hole9")));
  ((TextView) findViewById(R.id.front9hole10)).setText(c.getString(c.getColumnIndex("Hole10")));
  ((TextView) findViewById(R.id.front9hole11)).setText(c.getString(c.getColumnIndex("Hole11")));
  ((TextView) findViewById(R.id.front9hole12)).setText(c.getString(c.getColumnIndex("Hole12")));
  ((TextView) findViewById(R.id.front9hole13)).setText(c.getString(c.getColumnIndex("Hole13")));
  ((TextView) findViewById(R.id.front9hole14)).setText(c.getString(c.getColumnIndex("Hole14")));
  ((TextView) findViewById(R.id.front9hole15)).setText(c.getString(c.getColumnIndex("Hole15")));
  ((TextView) findViewById(R.id.front9hole16)).setText(c.getString(c.getColumnIndex("Hole16")));
  ((TextView) findViewById(R.id.front9hole17)).setText(c.getString(c.getColumnIndex("Hole17")));
  ((TextView) findViewById(R.id.front9hole18)).setText(c.getString(c.getColumnIndex("Hole18")));
  p1 = Integer.parseInt(iden);
  Cursor c3 = save.rawQuery("Select *from " +data + " where Venue = '"+ courses +"'", null);
  c3.moveToFirst();
  int places = c3.getCount();
  if(places == 0){
  } else {
    if(p1 == 111){
      Cursor cc = save.rawQuery("Select *from " +data + " where Mobile = '"+ number +"'", null);
      cc.moveToFirst();
      count = cc.getCount();
      if(count == 0){
      } else {
        hole1 = cc.getString(cc.getColumnIndex("Hole1"));
        hole2 = cc.getString(cc.getColumnIndex("Hole2"));
        hole3 = cc.getString(cc.getColumnIndex("Hole3"));
        hole4 = cc.getString(cc.getColumnIndex("Hole4"));
        hole5 = cc.getString(cc.getColumnIndex("Hole5"));
        hole6 = cc.getString(cc.getColumnIndex("Hole6"));
        hole7 = cc.getString(cc.getColumnIndex("Hole7"));
        hole8 = cc.getString(cc.getColumnIndex("Hole8"));
        hole9 = cc.getString(cc.getColumnIndex("Hole9"));
        hole10 = cc.getString(cc.getColumnIndex("Hole10"));
        hole11 = cc.getString(cc.getColumnIndex("Hole11"));
        hole12 = cc.getString(cc.getColumnIndex("Hole12"));
        hole13 = cc.getString(cc.getColumnIndex("Hole13"));
        hole14 = cc.getString(cc.getColumnIndex("Hole14"));
        hole15 = cc.getString(cc.getColumnIndex("Hole15"));
        hole16 = cc.getString(cc.getColumnIndex("Hole16"));
        hole17 = cc.getString(cc.getColumnIndex("Hole17"));
        hole18 = cc.getString(cc.getColumnIndex("Hole18"));
      }
    } else if(p1 == 222) {
      Cursor cc = save.rawQuery("Select *from " +data + " where Mobile = '"+ number +"'", null);
      cc.moveToFirst();
      count = cc.getCount();
      if(count == 0){
      } else {
        hole1 = cc.getString(cc.getColumnIndex("Hole1"));
        hole2 = cc.getString(cc.getColumnIndex("Hole2"));
        hole3 = cc.getString(cc.getColumnIndex("Hole3"));
        hole4 = cc.getString(cc.getColumnIndex("Hole4"));
        hole5 = cc.getString(cc.getColumnIndex("Hole5"));
        hole6 = cc.getString(cc.getColumnIndex("Hole6"));
        hole7 = cc.getString(cc.getColumnIndex("Hole7"));
        hole8 = cc.getString(cc.getColumnIndex("Hole8"));
        hole9 = cc.getString(cc.getColumnIndex("Hole9"));
        hole10 = cc.getString(cc.getColumnIndex("Hole10"));
        hole11 = cc.getString(cc.getColumnIndex("Hole11"));
        hole12 = cc.getString(cc.getColumnIndex("Hole12"));
        hole13 = cc.getString(cc.getColumnIndex("Hole13"));
        hole14 = cc.getString(cc.getColumnIndex("Hole14"));
        hole15 = cc.getString(cc.getColumnIndex("Hole15"));
        hole16 = cc.getString(cc.getColumnIndex("Hole16"));
        hole17 = cc.getString(cc.getColumnIndex("Hole17"));
        hole18 = cc.getString(cc.getColumnIndex("Hole18"));
      }
    } else if(p1 == 333) {
      Cursor cc = save.rawQuery("Select *from " +data + " where Mobile = '"+ number +"'", null);
      cc.moveToFirst();
      count = cc.getCount();
      if(count == 0){
      }else{
        hole1 = cc.getString(cc.getColumnIndex("Hole1"));
        hole2 = cc.getString(cc.getColumnIndex("Hole2"));
        hole3 = cc.getString(cc.getColumnIndex("Hole3"));
        hole4 = cc.getString(cc.getColumnIndex("Hole4"));
        hole5 = cc.getString(cc.getColumnIndex("Hole5"));
        hole6 = cc.getString(cc.getColumnIndex("Hole6"));
        hole7 = cc.getString(cc.getColumnIndex("Hole7"));
        hole8 = cc.getString(cc.getColumnIndex("Hole8"));
        hole9 = cc.getString(cc.getColumnIndex("Hole9"));
        hole10 = cc.getString(cc.getColumnIndex("Hole10"));
        hole11 = cc.getString(cc.getColumnIndex("Hole11"));
        hole12 = cc.getString(cc.getColumnIndex("Hole12"));
        hole13 = cc.getString(cc.getColumnIndex("Hole13"));
        hole14 = cc.getString(cc.getColumnIndex("Hole14"));
        hole15 = cc.getString(cc.getColumnIndex("Hole15"));
        hole16 = cc.getString(cc.getColumnIndex("Hole16"));
        hole17 = cc.getString(cc.getColumnIndex("Hole17"));
        hole18 = cc.getString(cc.getColumnIndex("Hole18"));
      }
    } else if(p1 == 444) {
      Cursor cc =save.rawQuery("Select *from " +data + " where Mobile = '"+ number +"'", null);
      cc.moveToFirst();
      count = cc.getCount();
      if(count == 0){
      }else{
        hole1 = cc.getString(cc.getColumnIndex("Hole1"));
        hole2 = cc.getString(cc.getColumnIndex("Hole2"));
        hole3 = cc.getString(cc.getColumnIndex("Hole3"));
        hole4 = cc.getString(cc.getColumnIndex("Hole4"));
        hole5 = cc.getString(cc.getColumnIndex("Hole5"));
        hole6 = cc.getString(cc.getColumnIndex("Hole6"));
        hole7 = cc.getString(cc.getColumnIndex("Hole7"));
        hole8 = cc.getString(cc.getColumnIndex("Hole8"));
        hole9 = cc.getString(cc.getColumnIndex("Hole9"));
        hole10 = cc.getString(cc.getColumnIndex("Hole10"));
        hole11 = cc.getString(cc.getColumnIndex("Hole11"));
        hole12 = cc.getString(cc.getColumnIndex("Hole12"));
        hole13 = cc.getString(cc.getColumnIndex("Hole13"));
        hole14 = cc.getString(cc.getColumnIndex("Hole14"));
        hole15 = cc.getString(cc.getColumnIndex("Hole15"));
        hole16 = cc.getString(cc.getColumnIndex("Hole16"));
        hole17 = cc.getString(cc.getColumnIndex("Hole17"));
        hole18 = cc.getString(cc.getColumnIndex("Hole18"));
      }
    }
  }
  ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(
    this,
    R.layout.spinnerlayout,
    new String[] { hole1,"1", "2", "3", "4","5","6","7","8","9" });
    adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(
      this,
      R.layout.spinnerlayout,
      new String[] { hole2,"1", "2", "3", "4","5","6","7","8","9" });
      adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole3,"1", "2", "3", "4","5","6","7","8","9" });
      adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter4 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole4,"1", "2", "3", "4","5","6","7","8","9" });
      adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter5 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole5,"1", "2", "3", "4","5","6","7","8","9" });
      adapter5.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter6 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole6,"1", "2", "3", "4","5","6","7","8","9" });
      adapter6.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter7 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole7,"1", "2", "3", "4","5","6","7","8","9" });
      adapter7.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter8 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole8,"1", "2", "3", "4","5","6","7","8","9" });
      adapter8.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter9 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole9,"1", "2", "3", "4","5","6","7","8","9" });
      adapter9.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter10 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole10,"1", "2", "3", "4","5","6","7","8","9" });
      adapter10.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter11 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole11,"1", "2", "3", "4","5","6","7","8","9" });
      adapter11.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter12 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole12,"1", "2", "3", "4","5","6","7","8","9" });
      adapter12.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter13 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole13,"1", "2", "3", "4","5","6","7","8","9" });
      adapter13.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter14 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole14,"1", "2", "3", "4","5","6","7","8","9" });
      adapter14.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter15 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole15,"1", "2", "3", "4","5","6","7","8","9" });
      adapter15.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter16 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole16,"1", "2", "3", "4","5","6","7","8","9" });
      adapter16.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter17 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole17,"1", "2", "3", "4","5","6","7","8","9" });
      adapter17.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      ArrayAdapter<String> adapter18 = new ArrayAdapter<String>(
        this,
        R.layout.spinnerlayout,
        new String[] { hole18,"1", "2", "3", "4","5","6","7","8","9" });
      adapter18.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      Spinner spinner = (Spinner)this.findViewById(R.id.soloscorehole1front9);
      spinner.setAdapter(adapter1);
      ((Spinner) findViewById(R.id.soloscorehole2front9)).setAdapter(adapter2);
      ((Spinner) findViewById(R.id.soloscorehole3front9)).setAdapter(adapter3);
      ((Spinner) findViewById(R.id.soloscorehole4front9)).setAdapter(adapter4);
      ((Spinner) findViewById(R.id.soloscorehole5front9)).setAdapter(adapter5);
      ((Spinner) findViewById(R.id.soloscorehole6front9)).setAdapter(adapter6);
      ((Spinner) findViewById(R.id.soloscorehole7front9)).setAdapter(adapter7);
      ((Spinner) findViewById(R.id.soloscorehole8front9)).setAdapter(adapter8);
      ((Spinner) findViewById(R.id.soloscorehole9front9)).setAdapter(adapter9);
      ((Spinner) findViewById(R.id.soloscorehole10front9)).setAdapter(adapter10);
      ((Spinner) findViewById(R.id.soloscorehole11front9)).setAdapter(adapter11);
      ((Spinner) findViewById(R.id.soloscorehole12front9)).setAdapter(adapter12);
      ((Spinner) findViewById(R.id.soloscorehole13front9)).setAdapter(adapter13);
      ((Spinner) findViewById(R.id.soloscorehole14front9)).setAdapter(adapter14);
      ((Spinner) findViewById(R.id.soloscorehole15front9)).setAdapter(adapter15);
      ((Spinner) findViewById(R.id.soloscorehole16front9)).setAdapter(adapter16);
      ((Spinner) findViewById(R.id.soloscorehole17front9)).setAdapter(adapter17);
      ((Spinner) findViewById(R.id.soloscorehole18front9)).setAdapter(adapter18);
      ((Spinner) findViewById(R.id.soloscorehole2front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole3front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole4front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole5front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole6front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole7front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole8front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole9front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole10front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole11front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole12front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole13front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole14front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole15front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole16front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole17front9)).setEnabled(false);
      ((Spinner) findViewById(R.id.soloscorehole18front9)).setEnabled(false);
    } 

This is what logcat says:

01-20 17:16:54.742: E/AndroidRuntime(28665): FATAL EXCEPTION: AsyncTask #1
01-20 17:16:54.742: E/AndroidRuntime(28665): java.lang.RuntimeException: An error occured while executing doInBackground()
01-20 17:16:54.742: E/AndroidRuntime(28665): at
android.os.AsyncTask$3.done(AsyncTask.java:299)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.FutureTask.setException(FutureTask.java:124)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
java.lang.Thread.run(Thread.java:856)
01-20 17:16:54.742: E/AndroidRuntime(28665): Caused by:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
01-20 17:16:54.742: E/AndroidRuntime(28665): at
android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4607)
01-20 17:16:54.742: E/AndroidRuntime(28665): at
android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:835)

  • 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-17T11:44:34+00:00Added an answer on June 17, 2026 at 11:44 am

    You’re getting an error because you’re calling loading() from a background thread in doInBackground(). In loading(), you’re modifying aspects of the UI. This is not allowed on any thread except the Main UI thread, and you get an exception because you do it from the background thread.

    You should ideally be doing all this UI modification in onPostExecute(), but you can also wrap the parts which alter the UI in a runOnUiThread.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am writing an app for my school newspaper, which is run completely online
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.