安卓:重新调用的应用程序,如果任务管理器杀 [英] Android: Re-invoke application if task manager kill

查看:248
本文介绍了安卓:重新调用的应用程序,如果任务管理器杀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序线程亲近如果杀害了任务管理器。需要重新调用的应用程序,就好像它被其他应用程序或任务管理器杀了。你知道吗?

Application thread get close if its killed by task manager. Need to re-invoke application as though its killed by other application or task manager. Any idea?

推荐答案

您必须运行与START_STICKY命令的后台服务。 只是延伸服务和覆盖按需这样的:

You have to run background service with START_STICKY command. Just extends Service and override onCommand like this :

@Override
public int onStartCommand(Intent intent,int flags,int startId) {
    super.onStartCommand(intent, flags, startId);

    return START_STICKY;
}

就像这是你的服务是重新启动时,它的关闭(由系统或其他任何东西)

Like this your Service is restart when it's close (by system or anything else)

您刚才已立即检查你的服务(的onCreate为例),如果应用程序正在运行或没有,如果没有重新启动它。我想PackageManager让你检查这还是简单地把一个静态布尔is_alive,看看你的活动一直在运行。

You just have now check on your service (onCreate for example) if application is running or not and launch it again if not. I suppose PackageManager let you check this or simply put a static boolean is_alive to see if your activity is always running.

问候 吉姆

这篇关于安卓:重新调用的应用程序,如果任务管理器杀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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