public class JsonServer extends AsyncTask<Void,Void,JSONObject> { private Context context; private ProgressDialog progressDialog; private String str; public JsonServer(Context context,String str){ this.context=context; this.str=str; } @Override protected void onPreExecute() { super.onPreExecute(); progressDialog=new ProgressDialog(context); progressDialog.setTitle("Получение данных"); progressDialog.show(); } @Override protected JSONObject doInBackground(Void... params) { try { Thread.sleep(2500); } catch (InterruptedException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(JSONObject jsonObject) { super.onPostExecute(jsonObject); progressDialog.dismiss(); } } How to call get from AsyncTask to make ProgressDialog work?