- Code: Select all
//---------------- AUTHENTICATE LOGIN ---------------------------
public static String authenticateLogin (String usr, String password, String updateDataNames, String updateDataUsernames, String updateDataPhone, String updateDataRadius, String updateDataChecked, String updateGPS)
{
String result = "";
ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("LoginUSR", usr));
pairs.add(new BasicNameValuePair("LoginPASS", password));
pairs.add(new BasicNameValuePair("Names", updateDataNames));
pairs.add(new BasicNameValuePair("Usernames", updateDataUsernames));
pairs.add(new BasicNameValuePair("Phone", updateDataPhone));
pairs.add(new BasicNameValuePair("Radius", updateDataRadius));
pairs.add(new BasicNameValuePair("Checked", updateDataChecked));
pairs.add(new BasicNameValuePair("GPS", updateGPS));
try
{
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.[URL REMOVED].com/file.php");
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
final InputStream is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
is.close();
result=sb.toString();
}
catch(Exception e)
{
Log.e("log_tag", "Error in http connection "+e.toString());
}
//-------------------------------------
return result;
}
}
EDIT: This thread better describes the problem I'm having and the reason why: http://stackoverflow.com/questions/1037 ... -ics-fails
Apparently I can not do networking on main thread, I have to move it to a background thread, or use AsyncTask. I'm really not sure what either of those things mean / how to do them (newbie programmer here). Any help is appreciated.


