 <p>Of course, in the second activity to make the users unable to go back to the login screen you use this code in the second activity overriding the back button functionality</p> <pre><code>@override public void onBackPressed() { } </code></pre> <p>And to go back to the log in screen, you can use the following code inside the function that delegates the button's click:</p> <pre><code>private void onClickLogOutButton() { Intent intent = new Intent(this, LogInActivity.class); startActivity(intent); this.finish(); } </code></pre> <p>The this.finish() will close the instance of the activity of the second screen, this will avoid the users to go back to the second activity pressing the back button.</p>