I am writing a program to validate log-in which cannot work. Not occurring any error but it does not generate toast text for incorrect log-in. I consider it goes wrong on condition state. If the log-in is wrong, it will response a 'null' as it display in the log.
But I can't find where the fault is, can somebody help?
HttpClient client = new DefaultHttpClient();
try {
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("login", loginText));
parameters.add(new BasicNameValuePair("password", pwText));
String url = controller.bniRootUrl+
controller.folderUser+
controller.fileLogin+
"?";
url += URLEncodedUtils.format(parameters, "utf-8");
HttpGet get = new HttpGet(url);
HttpResponse response = client.execute(get);
loginResponse = EntityUtils.toString(response.getEntity());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d(TAG, "response: "+loginResponse);
if (loginResponse == null || loginResponse == "null" || loginResponse.isEmpty()){
Toast.makeText(Login.this, "invalid login", Toast.LENGTH_SHORT).show();
}