For myself, I do this using the callback function that I call after onPostExecute.
public AsyncUnzip(Activity ctx, Observer callback) {
this.ctx = ctx;
this.callback = callback;
}
and
@Override
protected void onPreExecute() {
super.onPreExecute();
dia = new ProgressDialog(ctx);
dia.setTitle("Bitte warten");
dia.setMessage("Geodatenpaket wird entpackt...");
dia.setCancelable(false);
dia.show();
}
and
@Override
public void onPostExecute( Boolean result ) {
super.onPostExecute(result);
dia.dismiss();
callback.update(null, returnFolder);
System.out.println("Unzipped to: " + returnFolder.getName() );
}
In this case, your Async Task call will look like this:
AsyncUnzip unzipThread = new AsyncUnzip(ImportActivity.this, new Observer() {
@Override
public void update( Observable observable, Object data ) {
} });
unzipThread.execute(selectedFile);
Note. This is a quick and diry solution with an anonymous Observer implementation and no observable.
source
share