文字列の比較が機能しない理由がわかりません
protected String doInBackground(String... args)
{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_login);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity entity = httpResponse.getEntity();
InputStream is = entity.getContent();
String returnState = new String();
returnState = convertStreamToString(is);
Log.d("retunState ", returnState); // returning desired string
//if (returnState=="user") // this is not working, however returnState = user
// OR
//if (returnState.equals("user"))
// OR
if (returnState.equalsIgnoreCase("user")) // this is not working also
{
Intent i = new Intent(Main.this, SecondPage.class);
startActivity(i);
finish();
}
} // close of doInbackgorund function
private static String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append((line + "\n"));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
3つすべてのif条件でエラーが発生することはなく、returnState=userまたはreturnState=no_userであっても、2番目のアクティビティは開始されません。returnState = userの場合は別のアクティビティを開始したいのですが、いずれの場合も、ブロックされた場合は開始されません。