I call method in webservice that return string “true” or “false” and take two parameters using the following code
String isLogedin = readTwitterFeed();
public String readTwitterFeed() {
String Result = null;
StringBuilder URL = new StringBuilder();
URL.append("http://localhost:1539/WCFService1/Service.svc/Login/");
URL.append(username.getText());
URL.append("/");
URL.append(password.getText());
/////////////////////////////
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(
URL.toString());
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
StringBuilder builder = null ;
String line = null;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
Result = builder.toString() ;
} else {
Result = "error";
}
} catch (ClientProtocolException e) {
Result = "error";
e.printStackTrace();
} catch (IOException e) {
Result = "error";
e.printStackTrace();
}
return Result;
}
but the returned string is always empty
any idea why it not return data, also it doesn’t display any error (I display the return value on textview), also I set the permission for internet like that
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
and am sure that the service is running
Localhostand127.0.0.1areAndroid emulated device'sown loopback interface,In other words, you connect to android emulated device (not to your computer) by usinglocalhostor127.0.0.1. if you’re trying to access your development machine use10.0.2.2.one thing in your code you did not intialize your
StringBuilder builderinitialize it like
StringBuilder builder = new StringBuilder();