How to close Android application?

后端 未结 22 1530
小蘑菇
小蘑菇 2020-11-22 07:17

I want to close my application, so that it no longer runs in the background.

How to do that? Is this good practice on Android platform?

If I rely on the \"ba

22条回答
  •  悲哀的现实
    2020-11-22 08:15

    I think it will close your activity and all Sub activity related to it.

    public boolean onOptionsItemSelected(MenuItem item) {
    
            int id = item.getItemId();]
            if (id == R.id.Exit) {
                this.finishAffinity();
                return true;
            }
    
            return super.onOptionsItemSelected(item);
        }
    

提交回复
热议问题