I have a question concerning the finish() method of an activity in android studio:
I have this simple code:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
In my activity_main I simply have a button. When I click on the button the activity finishes and I go back to the main screen of the device...However, when I click on the menu button of the device (which shows all the app running in background) I still see my activity... and I do not want that. How can I fix it?