starting android service using explicit vs implicit intent

后端 未结 2 2125
别那么骄傲
别那么骄傲 2021-02-14 09:41

According to the standard Android documentation, the prefered way to start a service (started service that is) is to use an explicit intent like this:

// Using e         


        
2条回答
  •  -上瘾入骨i
    2021-02-14 10:31

    You don't need to use an implicit intent to start a service or activity in a separate process; however, using a separate process for an Activity is a rare scenario. Using a separate process for a Service is more common, but nevertheless I'd like to know what the use case is.

    If your application process is destroyed and then restarted, you'd use startService to reconnect to the Service. If the Service is running, you connect to it, otherwise the Service is restarted. If you then want to kill the Service, you can kill it, or you can run stopService() from your main app.

    What is the service doing?

提交回复
热议问题