从php webservice获得结果“成功”时打开另一个活动但是没有用,android

I have used a php webservice where i am matching login credentials if true i pass "success", if false i pass "failure".

and In java code, i am matching result data and apply condition when will open another activity and when will show a toast for wrong credentials.

But when i put either wrong or right credentials it will always open another activity. never show a toast

So please help me , what should I do ?

my code

 @Override
    protected void onPostExecute(String result) {
        String str = result.trim();
        if(str=="success") {
            startActivity(new Intent(Login.this,MainActivity.class));
        }
        else{
            Toast.makeText(Login.this, "Either Username or Password is not correct", Toast.LENGTH_SHORT).show();
        }
        dialog.dismiss();
    }

my php code

$sql = "select * from master_login_tbl where user_id = '$user' or email='$user' and password = '$pass' ";
$result = mysql_query($sql);
$check = mysql_fetch_array($result);
$num_of_rows = mysql_num_rows($result);
if($num_of_rows > 0){echo "success";}else{echo 'failure';}

You need to use str.equals("success"), comparing strings in Java with == does not work because you compare the objects and not the string.

You can also use equalsIgnoreCase("success)", which, as the name suggests, ignores any upper or lower case differences.