While calling okhttp request, progressDialog not showing.I am showing the progress dialog before calling the request and dismiss the progress dialog after getting the repsonse. Here is the code.
progressDialog.show();
GetLogin logResp = new GetLogin();
try {
String response = logResp.run(Constants.LOGIN_URL +"username="+username+"&password="+password);
if (response != null) {
} catch(JSONException e){
e.printStackTrace();
progressDialog.dismiss();
}
}else{
progressDialog.dismiss();
}
} catch (IOException e) {
e.printStackTrace();
progressDialog.dismiss();
}
public class GetLogin {
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
}