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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:27:05+00:00 2026-06-17T13:27:05+00:00

I am trying to use ProgressDialog. when i run my app the Progress Dialog

  • 0

I am trying to use ProgressDialog. when i run my app the Progress Dialog box show and disappear after 1 second. I want to show it on completion of my process.. Here is my code:

public class MainActivity extends Activity {
android.view.View.OnClickListener mSearchListenerListener;
 private ProgressDialog dialog;

  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      new YourCustomAsyncTask().execute(new String[] {null, null});

      }



  private class YourCustomAsyncTask extends AsyncTask <String, Void, Void> { 

        protected void onPreExecute() { 
           dialog = new ProgressDialog(MainActivity.this); 
           dialog.setMessage("Loading...."); 
           dialog.setIndeterminate(true); 
           dialog.setCancelable(true); 
           dialog.show(); //Maybe you should call it in ruinOnUIThread in doInBackGround as suggested from a previous answer
        } 

        protected void doInBackground(String strings) { 
           try { 

            //  search(strings[0], string[1]);

              runOnUiThread(new Runnable() { 
                 public void run() { 
                  //  updateMapWithResult(); //Or call it onPostExecute before progressDialog's dismiss. I believe this method updates the UI so it should run on UI thread
                 } 
               }); 

           } catch(Exception e) {
           }


        }

    @Override 
    protected void onPostExecute(Void params) { 
        dialog.dismiss(); 
        //result 

    }

    @Override
    protected Void doInBackground(String... params) {
        // TODO Auto-generated method stub
        return null;
    } 

}
}

Updated Question:

        @Override
    public void onCreate(SQLiteDatabase db) {
        mDatabase = db;





          Log.i("PATH",""+mDatabase.getPath());



        mDatabase.execSQL(FTS_TABLE_CREATE);





        loadDictionary();
    }

    /**
     * Starts a thread to load the database table with words
     */
    private void loadDictionary() {
        new Thread(new Runnable() {
            public void run() {
                try {
                    loadWords();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();
    }

    private void loadWords() throws IOException {
        Log.d(TAG, "Loading words...");


        for(int i=0;i<=25;i++)

            {  //***// 


        final Resources resources = mHelperContext.getResources();
        InputStream inputStream = resources.openRawResource(raw_textFiles[i]);
        //InputStream inputStream = resources.openRawResource(R.raw.definitions);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

        try {





            StringBuilder sb = new StringBuilder();
            while ((word = reader.readLine()) != null)
            {
                sb.append(word);
            //  Log.i("WORD in Parser", ""+word);
            }


            String contents = sb.toString();
            StringTokenizer st = new StringTokenizer(contents, "||");
            while (st.hasMoreElements()) {
                String row = st.nextElement().toString();

                String title = row.substring(0, row.indexOf("$$$"));
                String desc = row.substring(row.indexOf("$$$") + 3);
                // Log.i("Strings in Database",""+title+""+desc);
                long id = addWord(title,desc);

                if (id < 0) {
                  Log.e(TAG, "unable to add word: " + title);
              }
            }

        } finally {
            reader.close();
        }

        }

        Log.d(TAG, "DONE loading words.");
    }

I want to show ProgressDialogue box untill all words are not entered in the database. This code is in inner calss which extends SQLITEHELPER. so how to can i use ProgressDialogue in that inner class and run my addWords() method in background.

  • 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-17T13:27:07+00:00Added an answer on June 17, 2026 at 1:27 pm

    You cannot have this

     runOnUiThread(new Runnable() { 
                     public void run() { 
                      //  updateMapWithResult(); //Or call it onPostExecute before progressDialog's dismiss. I believe this method updates the UI so it should run on UI thread
                     } 
                   }); 
    

    in your doInBackground().

    Progress dialog doesn’t take priority when there is some other action being performed on the main UI thread. They are intended only when the actions are done in the background. runonUIthread inside doInBackground will not help you. And this is normal behavior for the progressdialog to be visible only for few seconds.

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

Sidebar

Related Questions

I'm trying to use Progress Dialog with Async task in my Adroid app. But
i am trying to use Alert Dialog Box and Async Task in the activity
How can I use Progress Dialog box with for Loop. Means either inside the
I am trying to use a progress dialog while my webview is loading and
I was trying use a set of filter functions to run the appropriate routine,
I am trying use a Java Uploader in a ROR app (for its ease
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
HI, Im trying to show a ProgressDialog while the activity is loading. my problem
I am trying to display a progress dialog during downloading of data. Right now,
I'm trying to use a spinning ProgressDialog to tell the user when the program

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.