이것은 LoginActivity.java에있는 제 함수입니다.이 함수를 호출하는 버튼의 onclick입니다. 내가 HTTP를 Communication.So에 대한 AsynkTask를 호출하고이 함수에서ProcessDialog가 제대로 나타나지 않습니까?
public void postHttpRequest(String userId,String pass,TextView error){
RequestClient reqClient = new RequestClient(LoginActivity.this);
String AppResponse = null;
try {
url = "myurl";
Log.d("URL", url);
AppResponse = reqClient.execute().get();
String status = ValidateLoginStatus.checkLoginStatus(AppResponse);
Log.d("Status recived", status);
if(status.equals("200")){
saveInformation(userId,pass);
startingActivity(HOST_URL);
}else{
error.setText("Incorrect UserName or Password");
}
} catch (Exception e) {
Log.e("Exception Occured", "Exception is "+e.getMessage());
}
}
내가 한 sec.I에 대한 개방에 다음 내 processDialog를 응답을 geeting하고 때 버튼의 onclick을 내가 buttoon를 클릭 나의 processDialog 얻을해야합니다 열린 utill 내가 응답
public class RequestClient extends AsyncTask<String, Void, String>{
ProgressDialog pDialog;
Context context;
public RequestClient(Context c) {
context = c;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(context);
pDialog.setMessage("Authenticating user...");
pDialog.show();
}
@Override
protected String doInBackground(String... aurl){
String responseString="";
DefaultHttpClient httpClient=new DefaultHttpClient();
try {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(LoginActivity.url);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
responseString = EntityUtils.toString(resEntityGet);
Log.i("GET RESPONSE", responseString);
}
} catch (Exception e) {
Log.d("ANDRO_ASYNC_ERROR", "Error is "+e.toString());
}
Log.d("ANDRO_ASYNC_ERROR", responseString);
httpClient.getConnectionManager().shutdown();
return responseString;
}
@Override
protected void onPostExecute(String response) {
super.onPostExecute(response);
if(pDialog!=null)
pDialog.dismiss();
}
}
있어
그래서 내가 processDialog이 progressbialog에 스타일을 추가 // 장치
은 아마 당신은 onPostExecute에서 대화 상자를 닫습니다 않습니다. 거기에 중단 점을 넣고보십시오. –
진행 상황이 전혀 보이지 않습니까? – Dimmerg
응답을 얻은 후 단 1 초 만에 대화 상자가 열립니다. –