可能重复:
Quitting an application - is that frowned upon?的Android:调用Activity.finish()方法
我已经写了的应用程序,并覆盖onBackPress()方法:
@Override
public void onBackPressed() {
Log.e("Main Activity", "onBackPressed!");
exitAlert.show();//when the user click the ok button it will call the MainActivity.this.finish();
}
但我发现当调用finish()
函数。我仍然可以找到这个应用程序运行在“设置 - >应用程序 - > RunningServices“。所以我必须在这里手动停止它。 我不明白为什么仍然运行的时候调用了finish()
。 如何通过单击对话框销毁我的应用程序? 在此先感谢!