I want to use progress dialog with asynctask how could I use that.I tried but it showing me the dialog after getting the response .this is my calling function..to the asycnk task As I am expecting the issue I am facing is because of this AppResponse = reqClient.execute().get(); Because I have to get the return value also from this Async task .So please see both the files for refrence
void postHttpRequest(String userId,String pass,TextView error){
RequestClient reqClient = new RequestClient(IweenTravelLoginPage.this);
String AppResponse = null;
try {
url = "";
Log.d("Http Post URL is ", url);
AppResponse = reqClient.execute().get();
String status = ValidateLoginStatus.checkLoginStatus(AppResponse);
Log.d("Status recived", status);
if(status.equals("200")){
saveInformation(userId,pass);
startingActivity();
}else{
error.setText("Incorrect UserName or Password");
}
} catch (Exception e) {
Log.e("Exception Occured", "Exception is "+e.getMessage());
}
This function is for sending the request
public class RequestClient extends AsyncTask<String, Void, String>{
Context context;
public RequestClient(Context c) {
context = c;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... aurl){
String responseString="";
HttpClient client = null;
try {
client = new DefaultHttpClient();
HttpGet get = new HttpGet(IweenTravelLoginPage.url);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
responseString = EntityUtils.toString(resEntityGet);
Log.i("GET RESPONSE", responseString.trim());
}
} catch (Exception e) {
Log.d("ANDRO_ASYNC_ERROR", "Error is "+e.toString());
}
Log.d("ANDRO_ASYNC_RESPONSE", responseString.trim());
client.getConnectionManager().shutdown();
return responseString.trim();
}
@Override
protected void onPostExecute(String response) {
super.onPostExecute(response);
}
}
So please suggest me what I have to do to show the process dialog.I tried all the example on the stackoverflow .But that all are not working for me.Please help