如何自动重新启动该服务在android系统?

编程入门 行业动态 更新时间:2024-10-28 03:23:05
本文介绍了如何自动重新启动该服务在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经开始在Activity.Now服务,如果我强行关闭活动,然后自动的服务也迫使stopped.Is有什么办法可以自动重新启动它。?先谢谢了。

I have started a service in Activity.Now, if i force close the activity then automatically the service is also force stopped.Is there any way to restart it automatically.? Thanks in Advance.

推荐答案

您必须实施 onStartCommand()通过返回方法 START_STICKY 或 START_REDILIVER_INTENT ,但它是你的责任,通过调用停止服务 stopService()或 stopSelf()方法。

You must implement the onStartCommand() method by returning the START_STICKY or START_REDILIVER_INTENT, but it's your responsibility to stop the service by calling stopService() or stopSelf() method.

更多推荐

如何自动重新启动该服务在android系统?

本文发布于:2023-11-27 02:47:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   系统   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!