Skip to content Skip to sidebar Skip to footer

My If Statement Doesn't Work

I am writing a service application in Android. In this application, I am receiving commands from Main activity using onStartCommand event. The IF block is checking a variable. As y

Solution 1:

try with .equals will help you...

String is not Primary Data type in java

Always use .equals() when you have Object and String is Object

== is only for primitive data type and == in object compare your String Refrences...not value...

if(ReceivedCommandFromUser.equals("start"))
    {

      }

Solution 2:

When working with Strings in Java, use the .equals() method.

For example...

if(RecievedCommandFromUser.equals("start"){}

Should work.

Post a Comment for "My If Statement Doesn't Work"