This code isn’t working. The loading screen doesn’t show, however if I take out the http.load() it works fine.
Context ctx = v.getContext();
dialog = ProgressDialog.show(ctx, "Login", "Logging in...");
http.load();
http code:
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = newHttpPost("http://www.example.com/");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
result = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
}
That’s because you’re calling
http.load()from UI thread and it gets blocked until this call completes. You should use AsyncTask for that.