I'm having real problems getting a ProgressDialog up and running. My code:
ProgressDialog dialog;
try {
dialog = new ProgressDialog(context);
dialog.setCancelable(true);
dialog.setMessage("Loading ...");
// set the progress to be horizontal
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// set the bar to the default value of 0
dialog.setProgress(0);
// set the maximum value
dialog.setMax(100);
// display the progressbar
dialog.show();
}
catch (Exception e1)
{
e1.printStackTrace();
}
Below that I create my background thread to load some stuff and update the progress bar, but it never gets that far. In the stack trace I get "Unable to add window -- token null is not for an application", but the dialog seems (in the debugger) to have all the right things, it isn't null, but I'm getting this error.
Can anyone shine a light on this?