views:

62

answers:

2

I have been searching for an answer for this for some time now. I have an async task that downloads the database needed for my app, while this is downloading my app cant do anything as all the data it references is in this file, i have the app waiting for the file to be downloaded but i am attempting to show a progress dialog so the user knows something is happening while they wait for this to happen.

my code is currently

public class fileDownloader extends AsyncTask<Void, Integer, SQLiteDatabase> 
{
    private File dbFile;
    private ProgressDialog progressDialog;
    private Context context;
    private SQLiteDatabase database;
    private SQLiteDatabase.CursorFactory factory;

    public fileDownloader(Context c)
    {
        super();
        context = c;
    }
    @Override    
    protected void onPreExecute() 
    {       
        super.onPreExecute();
        progressDialog = new ProgressDialog(this.context);
        progressDialog.setMessage("Downloading Database...");
        progressDialog.setCancelable(false);
        progressDialog.setIndeterminate(true);
        progressDialog.show();
    }

    @Override
    protected SQLiteDatabase doInBackground(Void... v) 
    {        
     ....
    }

    @Override
    protected void onPostExecute(SQLiteDatabase db1)
    {
        progressDialog.dismiss();
    }

however nothing shows up i have also tried directly calling ProgressDialog.show in the pre execute and moving this to the calling activity with no luck.

please help!

A: 

Hmm - how long does your doInBackground method run? Maybe your dialog is shown, but the time is just too fast for the dialog to show up...

mreichelt
it takes about 1 - 2 minutes atm so more then long enough for the dialog to pop up and be seen.
Philderbeast