Saturday, 15 June 2013

java - Odd if Statement in android with reading json -


So I read a Jason API and removed the results. Based on the results, I want Android to perform two different things.

If situation = none, then I need an event and if situation = yes I should have another event.

My code is here:

  JSONObject json = new JSONObject (results); String position = json.getString ("status"); Log D. ("First", position); If (status == "no") {// toast login fail log d. ("Login-no", position); String message = "login failed"; Toast. Make Text (C, Message, Toast. LNNGHHORAT) Show (); } Else {// Get Username Log D. ("Login-yes", "correct"); // Get User ID // Set Preferences // Launch General Activity}   

The strange part is if my log shows the status = No, but depending on the log it seems that This other ...

  06-21 22: 24: 05.822: D / firstoffice (2688 9): no 06-21 22: 24: 05.877: D / login-yes (2688 9) ): Correct   

Based on this run it should not be in the second part of the statement ... what am I missing

< Div class = "post-text" itemprop = "text">

you two Tring (or to compare the contents of any two objects) for that thing can not == use . You are comparing the context, not the content.

If use (status.equals ("no")) {

No comments:

Post a Comment