0

I am creating a application for android, in which i am retrieving the name of sms gateway using the spinner. I have used api for sending sms, but my primary api is not supporting one website which other api support so i implemented if else validation to use the second api in case the user selects the website not supported by primary api. I am attaching the screenshot of the problem. Have a look at the code in red box and the log cat as well. The problem as you can see in the image is that even when the IF CONDITION is TRUE it is hitting ELSE part. What is causing such problem?

enter image description here

Tapan Desai
  • 848
  • 2
  • 14
  • 36

1 Answers1

7

Use .equals() to compare Strings in java.

== compares String Refrences(Memory Location)

.equals() compares Strings values.

Solution::

if(gateway_name.equals("ultoo")){

}
Community
  • 1
  • 1
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134
  • For more info look http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – harshit Sep 20 '12 at 10:23
  • @SamirMangroliya you are absolutely right. i wanted it to mark as answer but it says **you can accept is as answer in 10 minutes** so i'll mark it later. – Tapan Desai Sep 20 '12 at 10:26