[英]Send data to the server when remove app from recent apps programmatically
I have an application that works with the database. 我有一个与数据库一起使用的应用程序。
When I exit the application when I click the "exit" button, it sends the data to the server. 当我单击“退出”按钮退出应用程序时,它将数据发送到服务器。 There is a bug: when I remove an app from the recent apps, data is not sent to the server.
有一个错误:当我从最近的应用程序中删除一个应用程序时,数据不会发送到服务器。
How can I fix this? 我怎样才能解决这个问题?
I want the data to be sent to the server when the application is removed from the recent apps. 我希望从最近的应用程序中删除该应用程序后,将数据发送到服务器。
You could spawn a Service during onDestroy
, which lets you know when the activity is finished, and send the data from there. 您可以在
onDestroy
期间生成一个Service,它可以让您知道活动何时完成,并从那里发送数据。
https://developer.android.com/guide/components/activities/activity-lifecycle.html https://developer.android.com/guide/components/activities/activity-lifecycle.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.