从启动菜单处理程序关闭事件 [英] Handle app closing event from Launcher's menu

查看:144
本文介绍了从启动菜单处理程序关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是,当用户关闭从Android的启动菜单,这将会对home键长按打开应用就知道:

我希望做一些操作,当用户关闭应用程序。

其实,我想用户每次他离开应用程序时退出,但只要他能在这个关闭App太,我来处理这个事件,然后让我的操作。

我试图谷歌这一个,但我找不到任何考虑这个。

我不希望覆盖的onStop()或的onDestroy(),只要用户可能会回到应用程序,然后,在这种情况下,我没有让我的变化。不建议此。我只是想做出改变,当用户关闭应用程序完全。

所以我的问题是:


  • 是不是有什么像 onApplicationDestroy()


  • 时,有可能使与服务器的连接,当用户以这种方式关闭应用程序通过一些价值?



解决方案

  

我希望做一些操作,当用户关闭应用程序。


这是不可能的。你的进程终止简单,不另行通知。


  

是不是像有什么onApplicationDestroy()?


没有。


  

时有可能使与服务器的连接,当用户以这种方式关闭应用程序通过一些价值?


没有。

请注意,没有什么用户刷卡您的应用程序了近期的任务列表(你在你的问题是什么描绘)和各种其它方案,包括与显著不同:


  • Android的终止您的后台进程,以腾出其他应用程序的内存


  • 用户使用第三方的任务maanger终止您的后台进程


What I want to do is to know when user closes the app from Android Launcher's menu, which gets opened on home button long click:

I want to do some operations when user closes the app.

Actually, I want user to logout each time he leaves the app, but as long as he can close app in this was too, I have to handle this event and then make my operations.

I've tried to google this one, but I couldn't find anything considering this.

I don't want to override onStop() or onDestroy(), as long as the user may come back to the app then, in that case I don't have to make my changes. Don't advice this. I only want to make changes, when user closes app entirely.

So my questions are:

  • Isn't there anything like onApplicationDestroy()?

  • Is it possible to make connection with server and pass some values when user closes app in this way?

解决方案

I want to do some operations when user closes the app.

That is not possible. Your process is simply terminated, with no notice.

Isn't there anything like onApplicationDestroy()?

No.

Is is possible to make connection with server and pass some values when user closes app in this way?

No.

Note that there is nothing significantly different between the user swiping your app off the recent-tasks list (what you depict in your question) and various other scenarios, including:

  • Android terminating your background process to free up memory for other applications

  • Users terminating your background process using a third-party task maanger

这篇关于从启动菜单处理程序关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆