问题 in my MainActivity, which extends from AppCompatActivity, I want to override the onBackPressed method like so: @Override public void onBackPressed() { Log.d("MainActivity","onBackPressed"); Toast.makeText(getApplicationContext(),"onBackPressed",Toast.LENGTH_SHORT).show(); } but onBackPressed does not get called. How ever if I do not override onBackPressed, the application closes, when I press the backbutton and if I do override it it doesn't. The rest of my activity looks like this: public