My if statement doesn't work
I am writing a utility application in Android
. In this application, I receive commands from the main activity using an event onStartCommand
. The block IF
checks the variable. As you can see in the picture (debug mode) the value is "start", but the operator IF
doesn't work and is redirected to Else
. why?
source to share
try with .equals
will help you ...
String is not Primary Data type in java
Always use .equals() when you have Object
andString is Object
==
is only for primitive data type
and ==
in an object to compare your values String Refrences ... not value ...
if(ReceivedCommandFromUser.equals("start"))
{
}
source to share