Simple if statement not working properly
<pre><code>    int sch = 1;

    if (sch == 1){
        Log.d("check", "1");
    }
    if (sch == 2){
        Log.d("check", "2");
    }
    else {
        Log.d("check", "error!");
    }
</code></pre>

<p>This is an extremely simple statement.</p>

<p>I am using exact same statement in my android java code,</p>

<p>And it shows <code>check: 1</code> in logcat as supposed.</p>

<p>And when i get to real code i am using,</p>

<pre><code>    int sch = 1;

    if (sch == 1){
        activity.getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.white));
        if (android.os.Build.VERSION.SDK_INT &gt;= 21) {
            activity.getWindow().setNavigationBarColor(getResources().getColor(R.color.white));
            activity.getWindow().setStatusBarColor(getResources().getColor(R.color.red));}

        Log.d("check", "1");
    }

    if (sch == 2){            
        activity.getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.white));
        if (android.os.Build.VERSION.SDK_INT &gt;= 21) {
            activity.getWindow().setNavigationBarColor(getResources().getColor(R.color.white));
            activity.getWindow().setStatusBarColor(getResources().getColor(R.color.green));}

        Log.d("check", "2");
    }
    else {
        activity.getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.white));
        if (android.os.Build.VERSION.SDK_INT &gt;= 21) {
            activity.getWindow().setNavigationBarColor(getResources().getColor(R.color.white));
            activity.getWindow().setStatusBarColor(getResources().getColor(R.color.white));}

        Log.d("check", "error");
    }
}
</code></pre>

<p>When i run this code, it should show <code>check: 1</code> on the logcat and show red on the status bar.</p>

<p>but it shows like this :</p>

<pre><code>check: 1
check: error
</code></pre>

<p>And shows white on the status bar.</p>

<p>This is the exact code, and i didn't find anything wrong.</p>

<p>What could possibly be the problem?</p>