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 I am calling the operation as follows: class operation Do not use if You need to refer to something in and refer to it in the constructor .get () to complete. But this method
block my progress dialog, how can I get the
progress_dialog or change the
.get () Am I
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 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 * /}}
. () 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
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);
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