java - How to let Async Task finish in Android -


i'm working on app retrieves data network, stores them device , reads them. problem is, data in async task.. , app doesn't let task finish before trying show data user.. i've tried task.get() without result (it stops there).

here task:

public getoptionstask(xmlportalgetoptions request) {         super(request);     }     protected void oncancelled(){         // todo afficher message pas d'options sur le disque     }     @override     public void handleerror(transaction transaction) {         // todo afficher message pas d'options sur le disque     }     @override     public void handlesuccess(transaction transaction) {         saveoptions(transaction.getresponse());         request = null;         log.d(optionsmanager.class.getname(), this.getstatus().tostring());     } 

this task instance of custom async task:

protected basexmltransaction request;  public abstract void handleerror(transaction transaction); public abstract void handlesuccess(transaction transaction); public transactiontask(basexmltransaction request){     this.request = request; } @override protected void doinbackground(void... params) {     try {         log.i(transactiontask.class.getname(), "doing in background");         sockethandler.sendtransaction(this, request.getrequest());     } catch (sockethandlernotconfiguredexception e) {         log.e(transactiontask.class.getname(), "sockethandler's parameters not set.");     }     return null; } @override public void transactionresult(transaction transaction) {     switch (transaction.getcode()) {         case error:             log.e(transactiontask.class.getname(), "error !!!");             handleerror(transaction);             break;         case no_client:             log.e(transactiontask.class.getname(), "no client error");             handleerror(transaction);             break;         case no_server:             log.e(transactiontask.class.getname(), "no server error");             handleerror(transaction);             break;         case old_version:             log.e(transactiontask.class.getname(), "old version");             handleerror(transaction);             break;         case timeout:             log.e(transactiontask.class.getname(), "transaction timeout");             handleerror(transaction);             break;         case success:             log.i(transactiontask.class.getname(), "transaction success");             handlesuccess(transaction);     } } 

i don't know do... execute goes fast , doesn't since i'm not returning guess.

onpostexecute(result), invoked on ui thread after background computation finishes. result of background computation passed step parameter.

@override protected void onpostexecute(string result) {  } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -