开发者

Place Exit Button On Android Application

开发者 https://www.devze.com 2023-02-18 23:19 出处:网络
I am developing one applicat开发者_如何学Pythonion. In that application I want to put Exit button.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消