且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RemoteService - 关闭发射活动后,重新启动

更新时间:2023-02-27 08:10:39

Android开发人员 - 服务:在如果该服务被声明为在前台(稍后讨论)中运行,则它几乎不会被杀死。否则,如果服务被启动,并且是长期运行的,则系统会降低其位置。在随着时间的推移,该服务将变得非常容易后台任务列表中杀死,如果您的服务已启动,则必须设计它优雅地处理重新启动该系统。

From Android Developers - Services : "if the service is declared to run in the foreground (discussed later), then it will almost never be killed. Otherwise, if the service was started and is long-running, then the system will lower its position in the list of background tasks over time and the service will become highly susceptible to killing—if your service is started, then you must design it to gracefully handle restarts by the system".

声明为您服务,在前台运行有特定的要求:一个前台服务必须提供一个通知状态栏,这是摆在持续的标题,这意味着该通知不能被解雇,除非服务停止或从前景除去。和请您的服务在前台运行,调用startForeground()。我知道你说你不希望它是一个前台的服务,但你必须生活在Android的参数规定了你。

Declaring your service to run in the foreground has specific requirements: "A foreground service must provide a notification for the status bar, which is placed under the "Ongoing" heading, which means that the notification cannot be dismissed unless the service is either stopped or removed from the foreground." and "To request that your service run in the foreground, call startForeground()." I know you said you don't want it to be a foreground service, but you have to live with the parameters Android sets out for you.