当我关闭一个应用程序被称为什么方法 [英] What method is being called when I close an app

查看:158
本文介绍了当我关闭一个应用程序被称为什么方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了所有有关活动的生命周期,它的方法。

I read all about the activity lifecycle and it's methods.

我还是couldt找到答案: 当我结束我的应用程序,从打开的应用程序菜单(在galaxy4它是在home键长preSS,在nexus5这是正确的按钮......)什么方法被调用?如果有的话?

I still couldt find an answer: When I close my app, from the "open apps" menu (in galaxy4 it's a long press on the home button, in nexus5 it's the right button ...) what method is being called? if any?

在换句话说,我的活动推出的一项服务。 我想终止服务,如果应用程序(活动)被关闭。 (在所有与所述onDestory是不可靠的多次来过这里)

In other words, my activity is launching a service. I want to terminate the service if the app (activity) is being closed. (onDestory is not reliable at all as said many times here before)

在此先感谢!

推荐答案

您将通过的onPause()然后的onStop()。在pre-蜂窝(API 11)的设备,你的应用程序可以在任何时间之后的onPause()返回杀害。没有更多的方法调用,期。后蜂窝,你会至少让的onStop()

You will go through onPause() then onStop(). On pre-Honeycomb (API 11) devices, your app can be killed at any time after onPause() returns. No more methods called, period. Post-Honeycomb you will at least get onStop().

这篇关于当我关闭一个应用程序被称为什么方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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