Place Exit Button On Android Application
I am developing one applicat开发者_如何学Pythonion. In that application I want to put Exit button. By clicking Exit Button I want to exit from application.
I used the following code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish();
It exit the application but not stop all activities which are running in that application.
Please give me some suggestion to solve this problem.
This question was discussed many times already. You shouldn't make any "exit" buttons in your application. That's against Android nature and best practices. Look at Is quitting an application frowned upon? for wider discussion.
try this
system.exit(0);
精彩评论