I am looking for some help! I have some code doing server auth and retrieving the response from server. When i execute it in eclipse in my java project I've got reddirrect response like :
<html><head><meta http-equiv="refresh" content="0;url=SiteIamLoggingPageURL/"/></head></html>
But when i am excecuting the same code in my android app, ive got response equal to the failed login scenario.
HttpPost post = new HttpPost(loginPageAdress);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//nameValuePairs.add(new BasicNameValuePair("remember", "1"));
nameValuePairs
.add(new BasicNameValuePair("email", "email"));
nameValuePairs.add(new BasicNameValuePair("password", "password"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
StringBuilder stringBuilder = new StringBuilder();
HttpResponse response = client.execute(post, httpContext);
BufferedReader rd = new BufferedReader(new InputStreamReader(response
.getEntity().getContent(), "UTF-8"));
String line = "";
while ((line = rd.readLine()) != null) {
stringBuilder.append(line).append("\n");
}
System.out.println(stringBuilder.toString());
What is the problem? oo Thank you for your time!
Sound like you forgot adding
<uses-permission android:name="android.permission.INTERNET" />
in AndroidManifest.xml. Have a look at this tutorial
It could be because your not executing the HTTP request on a separate Thread
. Read more about this here:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.