why should i use android service instead of java thread

后端 未结 7 2059
遥遥无期
遥遥无期 2021-02-02 12:56

I am confused with android services and java thread.

Please help me to understand in which scenario i should use them.

As per my understanding

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 13:24

    Why we need service is to avoid resource crunch. For example you opening an application after opening an another application so at the time your app added to the background task. While opening multiple application, ur app may killed by android system. So if ur app has service it won't be killed by the system because service is higher priority , even it may killed the app has service so that we using constant return type in onStartCommand(). Method. That's START_STICKY,START_NOT_STICKY and DELIVER_INTENT.

提交回复
热议问题