Reputation: 19
The inputstream shows output in logcat as "org.apache.http.conn.EofSensorInputStream@527021ec" and output throws error. It is bez the login fails or I have made any mistake in code. Plz help...Attached the logcat image below.
protected Void doInBackground(String... params) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(UrlLink);
try {
// Add user name and password
String username = "xaeroprasad";
String password = "ramesh88";
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("login", username));
nameValuePairs.add(new BasicNameValuePair("password", password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.v("SENCIDE", "Execute HTTP Post Request");
HttpResponse response = httpclient.execute(httppost);
InputStream is=response.getEntity().getContent();
Log.v("ddd",is.toString());
String line = "";
StringBuilder total = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
while ((line = rd.readLine()) != null) {
total.append(line);
}
Log.v("dfd",line);
} catch (IOException e) {
e.printStackTrace();
}
Logcat output: https://i.sstatic.net/rKZgE.png
Upvotes: 0
Views: 43
Reputation: 3993
try {
while ((line = rd.readLine()) != null) {
total.append(line);
}
Log.v("dfd",total); //<-- Edit this, its a Typo
} catch (IOException e) {
e.printStackTrace();
}
Upvotes: 0
Reputation: 44118
You're running a loop until line
is null:
while ((line = rd.readLine()) != null) {
total.append(line);
}
And when it's over (line == null
) you print the line
:
Log.v("dfd",line);
That throws an error because Log's second parameter can't be null.
You probably wanted to Log total
after the loop:
while ((line = rd.readLine()) != null) {
total.append(line);
}
Log.v("dfd", total);
Upvotes: 1