高优先级的Andr​​oid服务 [英] High priority Android services

查看:134
本文介绍了高优先级的Andr​​oid服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找到针对Android实现过的蓝牙视频流服务。

I'm looking into implementing an over-Bluetooth video streaming service for Android.

我如何确保:

  • 在该服务具有高优先级运行?我想,以减少等待时间。
  • 的服务是低的东西名单当内存吃紧被杀害?

推荐答案

有两个重要的事情,你需要做,以确保您的服务继续运行:

There are two important things you need to do to make sure your service keeps running:

  1. 请确保你调用 startService()代替(或补充)的结合。这将确保该服务继续运行,即使创建它的活动被杀死。

  1. Make sure you call startService() instead of (or in addition to) binding. This will make sure that the service continues running, even if the Activity that created it is killed.

使用 startForegroud()运行在前台的服务,让Android将不会回收它时,所需的内存。它需要你也可以创建一个通知,获取服务时实际启动,将在通知区域的图标,让用户知道你的服务仍在运行发布的。

Use startForegroud() to run the service in the foreground, so that Android won't reclaim it when memory is needed. It requires that you also create a Notification that gets published when the service actually starts, putting an icon in the notification area and letting the user know your service is still running.

有关详细信息:

<一个href="http://developer.android.com/reference/android/app/Service.html">http://developer.android.com/reference/android/app/Service.html <一href="http://developer.android.com/guide/topics/fundamentals/bound-services.html">http://developer.android.com/guide/topics/fundamentals/bound-services.html

这篇关于高优先级的Andr​​oid服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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