如何在我使用 Web 服务发送 post 后销毁 android activity?

How to destroy an android activity after when I sending a post with a web service?

我正在尝试使用通过 GlassFish in Java and save the data in a PostgreSQL 数据库完成的 Web 服务提交表单。我正在使用 AsyncTask 发送数据。我遇到的问题是,当我完成发送数据后,我想销毁 activity 和 return 到主页。

只需调用 finish(); 即可摧毁您的 Activity

当你想杀死 Activity 时调用 finish();

请参阅 link 进一步研究:How to kill an Android activity when leaving it so that it cannot be accessed from the back button?

如果你在子方法、监听器等中:

youractivityclass.this.finish();

如果您直接在 activity class 上,只需拨打

finish()