High priority Android services

前端 未结 2 981
悲&欢浪女
悲&欢浪女 2021-01-13 20:51

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

How can I ensure that:

  • the service runs with a high priority? I\'
2条回答
  •  庸人自扰
    2021-01-13 21:40

    If you are/were in the same situation as me, being forced to use bindService(), the solution was to set the

    Context.BIND_IMPORTANT

    flag in that call. That raises the service's priority to that of the binding app, which if it is the foreground app, is the highest possible. If you don't use that flag, the service needs to fight over a measly 10% of resources with all the other background services. (the other 90% are reserved for the foreground app).

    Note that manually setting the service's thread priority, without setting this flag during bindService(), makes no difference.

提交回复
热议问题