Button closeButton = findViewById(R.id.close_button); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } });Example 2: Suppose you have an activity named LoginActivity which is responsible for user authentication. Once the user is authenticated, the LoginActivity should be closed, and the user should be redirected to the HomeActivity. You can use the finish() method to achieve this as shown below: ```java if(isUserAuthenticated){ Intent intent = new Intent(LoginActivity.this, HomeActivity.class); startActivity(intent); finish(); }else{ // Display error message } ``` The package library for android.app.Activity is android.app.