Service: onTaskRemoved not called if started with bindService

前端 未结 1 778
醉话见心
醉话见心 2020-12-17 10:06

I have a Service in which the onTaskRemoved() method has been implemented.
When the service is started with startService() the function o

相关标签:
1条回答
  • 2020-12-17 11:07

    A service can be bound or started or both. It depends on how you implement onStartCommand and onBind say the docs.

    http://developer.android.com/guide/components/services.html

    But if you want your service to do both stay around and talk with clients over an IBinder then simply start the service and then bind to it.

    startService(new Intent(context, CustomerService.class));
    // Bind to the service
    bindService(new Intent(context, CustomerService.class),
                            mConnection, Context.BIND_AUTO_CREATE);
    
    0 讨论(0)
提交回复
热议问题