I've got an Activity with a Tabhost, all tabs are represented by Activities, one of them called BrowserTab.
All these Activities observe an Observable class, Data.
In BrowserTab, I call a method in Data, which retrieves some data from the internet. I want to notify the user with a ProgressDialog on calling this method. I tried it like this:
In BrowserTab:
public void loadXML(){
progressDialog = ProgressDialog.show(this, "", "Loading. Please wait...", true);
data.loadXML(getUrl());
}
public void update(Observable o, Object arg)
{
progressDialog.dismiss();
}
In Data:
public void loadXML(String url)
{
this.xml = new XMLParser().parse(url);
setChanged();
notifyObservers();
}
Like this, the ProgressDialog appears áfter loading, to dissapear again immediately.
When I create a new Thread in the loadXML(String url) method in Data, I get a "Activity has leaked window" exception when the Observers are notified.
I've searched for solutions to this problem, but I just can't figure out how to fix this. Anyone an idea?