.finish() is not working inside a nested if statement : <p>For some reason, I cant use .finish() to end my previous activity inside a nested if statement.</p>

<pre><code>if (id == R.id.nav_menu) {
        MenuFragment menuFragment = MenuFragment.newInstance("", "");
        FragmentManager manager = getSupportFragmentManager();
        manager.beginTransaction().replace(
                R.id.layout_for_fragment,
                menuFragment
        ).commit();
    } else if (id == R.id.nav_report) {
        if(status == 1){
            SharedPrefManager.getInstance(getApplicationContext()).logout();
            getApplicationContext().finish();
            startActivity(new Intent(getApplicationContext(), LoginActivity.class));
        }
    }
</code></pre>
