Can't figure why my application has such a slow response times with the button. It's not even particularly complex program and windows phone version seems to be working lot smoother.
Here's what happens when button is pressed.
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("https://mywebpage.com/file.php");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("u", username));
pairs.add(new BasicNameValuePair("p", passwd));
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
Okay I likely need to add crypting but for testing purposes so far plain text works fine.
However this takes very long, longer than it should really seeing response is just shorthish line. Browser call gets that return back almost immediately and seeing my phone can stream video without issues I don't think it's network speed issue either.
Also the button doesn't change colour to show it was clicked consistently. Sometimes it doesn't do that so user ends up pressing again. Not that bad here but on next intent there's another button so if you do that you could end up negating what you did(it's basically on/off switch).
Is my method of calling web page plain bad? I don't think it's asynchronous so it blocks the program. Is that the issue? If so how to call it so it doesn't block the system? Or is it just something I have to live with?
Here's what happens when button is pressed.
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("https://mywebpage.com/file.php");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("u", username));
pairs.add(new BasicNameValuePair("p", passwd));
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
Okay I likely need to add crypting but for testing purposes so far plain text works fine.
However this takes very long, longer than it should really seeing response is just shorthish line. Browser call gets that return back almost immediately and seeing my phone can stream video without issues I don't think it's network speed issue either.
Also the button doesn't change colour to show it was clicked consistently. Sometimes it doesn't do that so user ends up pressing again. Not that bad here but on next intent there's another button so if you do that you could end up negating what you did(it's basically on/off switch).
Is my method of calling web page plain bad? I don't think it's asynchronous so it blocks the program. Is that the issue? If so how to call it so it doesn't block the system? Or is it just something I have to live with?
. 