I have created an app in android studio and it uses a background service which has a method which starts a counter of seconds. I have created an if statement to test if the seconds are at 0 and when i debug the value seems to be correct but the condition is jumping straight to the else statement and i can not figure out why.
public void checkService(){
long secs = seconds;
String str = String.valueOf(secs);
if(str == "0")
{
Toast.makeText(this, "Not started", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "Running", Toast.LENGTH_SHORT).show();
}
}
It is jumping to the second esle even when the value is 0. The image shows the value of str when i was debugging.