0

I have an app which the moment the user starts running the app it register a new entry in a database. The thing is that when the user quits I would like to delete this registry in the database. I know doing al these inserts and deletes with JSON, MySQL and PHP but I dont know how to apply these functions when the user quits the application in the normal way. I would like to know if there is a function like public onBackPressed() where it does always the same thing but you can overwrite it.

Thanks

4

2 回答 2

1

有一个 onDestroy() 方法,当用户完成应用程序并释放资源时调用它,你可以在你的活动中覆盖它并做你想做的任何事情,如果你想从 onDestroy() 上一步它是 onStop () 当活动进入后台等时调用。您也可以覆盖它。

于 2013-06-25T08:04:09.667 回答
1

使用 Android 的 onBackPressed() 方法并删除超级调用并执行所有操作,在最后阶段,编写 finish(),这将关闭您的应用程序。

这仅在您的其他活动关闭时才有效,否则它将关闭当前活动并转到最后一个活动。

于 2013-06-25T12:12:26.117 回答