繁体   English   中英

在android生命周期中,当从最近的应用列表中滑动应用时,是否会调用任何独特的方法?

[英]In android lifecycle, is there any unique method gets called when app is swiped from recent app list?

在android生命周期中,当从最近的应用列表中滑动应用时,是否有任何独特的方法被调用? 我们最初认为我们会使用 onDestroy,但它也会在其他活动中被调用。

添加如下服务并启动它。 当应用程序关闭 onTaskRemoved 运行您的代码。

显现

<service
    android:enabled="true"
    android:name=".ExitService"
    android:exported="false"
    android:stopWithTask="false" />

服务等级

public class ExitService extends Service {

@Override
public void onStartService() {}

@Override
public void onTaskRemoved(Intent rootIntent) {
    super.onTaskRemoved(rootIntent);
    this.stopSelf();
}}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM