I need to display a progress sign. It is quite simple, though I must wait completely unless Aynccutcus will not be finished. This boycotts some difficulties for me Asynctask method is used to wait for .get () to complete. But this method
block my progress dialog, how can I get the
progress_dialog or change the
.get () Am I
I am calling the operation as follows:
operation o = new operation (); O.execute (parameter); Try {o.get (); } Grip (Interrupted E) E. {// TODO Auto-Generated Catch Block e.printStackTrace (); } Hold (execution exception e) {// TODO auto generated blocking block e.printStackTrace (); } class operation
class operation AsyncTask and lt; String, zero, JSONObject & gt; {Progress DIOLOG PD; Context associated; Prerequirer protected override @ (zero); new progressivity (AP); Pd.setOwnerActivity (app); Pd.setTitle ("Ð ?? Ð'ÐμÑ ?? Ð · Ð ° Ð³Ñ ?? Ñ ?? Ð · кР° ..."); Pd.setCancelable (true); Pd.show (); } @ Override protected JSONObject doInBackground (string ... option) {/ * some jobs * / return Jason; } @Override Secure Zero PostExecute (JSONObject Results) {super.onPostExecute (Results); Pd.dismiss (); / * Some jobs * /}}
Do not use . () As you have seen, it blocks UI . You can use getStatus () if you want to check whether the job is finished or not. Deleting .get () should allow you to show the ProgressDialog . If you have a code that will have to wait until the AsyncTask is finished, call it at PostExecute () at or a function in
if You need to refer to something in main activity asyncTask after completion of it, just create a constructor to get a reference of your activity And pass context your manufacturer
operation o = new operation (this); and refer to it in the constructor
lass operation AsyncTask & lt; String, zero, JSONObject & gt; {Progress DIOLOG PD; Context associated; Activity act; Public operator (activity action) {act = curact; // This reference can be used to access methods in your activity}
No comments:
Post a Comment