Use 0 or BIND_AUTO_CREATE for bindService's flag

前端 未结 2 720
再見小時候
再見小時候 2021-02-18 18:15

By referring to bindService (Intent service, ServiceConnection conn, int flags)

May I know, when should we use 0 for flags, and when should we should we use

2条回答
  •  借酒劲吻你
    2021-02-18 18:53

    For method bindService(Intent, ServiceConnection, flag) if flag = Context.BIND_AUTO_CREATE is used it will bind the service and start the service, but if "0" is used, method will return true and will not start service until a call like startService(Intent) is made to start the service. One of the common use of "0" is in the case where an activity to connect to a local service if that service is running, otherwise you can start the service.

提交回复
热议问题