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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:34:49+00:00 2026-05-24T13:34:49+00:00

I am trying to display a progress dialog when the app runs for the

  • 0

I am trying to display a progress dialog when the app runs for the first time since it installs database and takes a while to do that because of the DB size. Here is the ListAcitity that I am using:
package samples.employeedirectory;

import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ListAdapter;
import android.widget.ListView;

public class EmployeeList extends ListActivity {

protected SQLiteDatabase db;
protected Cursor cursor;
protected ListAdapter adapter;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    new progressBar().execute();
    db = (new DatabaseHelper(this)).getWritableDatabase();
    cursor = db.rawQuery("SELECT * FROM employeeList", new String[]{});

    adapter = new qCursorAdapter(this, cursor);

    // requestWindowFeature(Window.FEATURE_NO_TITLE);
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setListAdapter(adapter);

}

public void onListItemClick(ListView parent, View view, int position, long id) {
    Intent intent = new Intent(this, displayEmployee.class);
    Cursor cursor = (Cursor) adapter.getItem(position);
    intent.putExtra("eID", cursor.getInt(cursor.getColumnIndex("eID")));
    startActivity(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.pref:
            // Launch Preference activity
            Intent intent = new Intent(this, Preferences.class);
            startActivity(intent);
         break;
    }
    return true;
}

}

I realized then that I can’t display progress bar before the activity starts. What is the best approach to achieve this?

Edit:
Using this code:

package samples.employeedirectory;

import android.app.ProgressDialog;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;

public class progressBar extends AsyncTask<String, Void, String> {
protected Context context;
protected SQLiteDatabase db;
protected ProgressDialog dialog;
@Override
protected String doInBackground(String... params) {
    db = (new DatabaseHelper(context)).getWritableDatabase();
    return null;
}

/* (non-Javadoc)
 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
 */
@Override
protected void onPostExecute(String result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);
    dialog.dismiss();
}

/* (non-Javadoc)
 * @see android.os.AsyncTask#onPreExecute()
 */
@Override
protected void onPreExecute() {
    // super.onPreExecute();
dialog = ProgressDialog.show(context, "",
            "Please wait for few seconds...", true);
}

/* (non-Javadoc)
 * @see android.os.AsyncTask#onProgressUpdate(Progress[])
 */
@Override
protected void onProgressUpdate(Void... values) {
    // TODO Auto-generated method stub
    super.onProgressUpdate(values);
}

}

I received these errors:

    08-15 23:21:26.743: ERROR/AndroidRuntime(5170): java.lang.RuntimeException: Unable to start activity ComponentInfo{samples.employeedirectory/samples.employeedirectory.EmployeeList}: java.lang.NullPointerException
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.os.Handler.dispatchMessage(Handler.java:99)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.os.Looper.loop(Looper.java:123)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread.main(ActivityThread.java:3701)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at java.lang.reflect.Method.invokeNative(Native Method)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at java.lang.reflect.Method.invoke(Method.java:507)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at dalvik.system.NativeStart.main(Native Method)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170): Caused by: java.lang.NullPointerException
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.Dialog.<init>(Dialog.java:141)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.AlertDialog.<init>(AlertDialog.java:67)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ProgressDialog.<init>(ProgressDialog.java:80)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ProgressDialog.<init>(ProgressDialog.java:76)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ProgressDialog.show(ProgressDialog.java:101)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ProgressDialog.show(ProgressDialog.java:90)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at samples.employeedirectory.progressBar.onPreExecute(progressBar.java:34)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.os.AsyncTask.execute(AsyncTask.java:391)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at samples.employeedirectory.EmployeeList.onCreate(EmployeeList.java:27)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    08-15 23:21:26.743: ERROR/AndroidRuntime(5170):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
  • 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-24T13:34:50+00:00Added an answer on May 24, 2026 at 1:34 pm

    you can use the Asyntask concept
    in Preexecute() start the progress dialogue
    in doinginbackground() method install the DB
    in postexecute() stop the dialogue

    refer this

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

Sidebar

Related Questions

I'm trying to display a loading icon while my iPhone app downloads a network
I am trying to display the progress bar(marque) in a separate form (progressForm) while
I am trying to display a progress dialog during downloading of data. Right now,
I'm trying to display a ProgressDialog to indicate that the user should wait while
I'm trying to display an update progress loading image whenever my update panel does
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I am trying to display a pie chart that shows sales by company. However
I am trying to display an indefinite ProgressDialog, while an AsyncTask binds to a
I'm trying to display multiple, static jQuery Progress Bars on a single page, all
I am trying to display the progress of multiple xhr sends in a table

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.