Avoid from being killed

本文介绍了Android中前台进程的概念,包括活动、服务和广播接收器等组件如何构成前台进程,并讨论了在内存紧张时系统如何处理这些进程。还提供了一种防止应用被任务管理器杀死的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Foreground process
A process that is required for what the user is currently doing. A process is considered to be in the foreground if any of the following conditions are true:
It hosts an Activity that the user is interacting with (the Activity's onResume() method has been called).
It hosts a Service that's bound to the activity that the user is interacting with.
It hosts a Service that's running "in the foreground"—the service has called startForeground().
It hosts a Service that's executing one of its lifecycle callbacks (onCreate()onStart(), oronDestroy()).
It hosts a BroadcastReceiver that's executing its onReceive() method.
Generally, only a few foreground processes exist at any given time. They are killed only as a last resort—if memory is so low that they cannot all continue to run. Generally, at that point, the device has reached a memory paging state, so killing some foreground processes is required to keep the user interface responsive.




http://stackoverflow.com/questions/2785843/how-can-i-prevent-my-android-app-service-from-being-killed-from-a-task-manager

You can write a helper app to receive android broadcast"android.intent.action.PACKAGE_RESTARTED",when your app got killed,your helper will receive that broadcast and you can restart your app or whatever.
That's how 'Smart App Protector Free' do.
The bad thing is users must install two apps instead of one.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值