androidservicebindunbind

Android - bindService more than once


Is it ok to use bindService more than once with the same context to the same service ?

Can I use bindService multiple times with the same context to the same service and unBindService only once ?

Thanks


Solution

  • It is possible to bind multiply times to the same service with the same context, but it is looks to me as bad practice. Also, you cannot unbind from service only once. You must unbind all your ServiceConnection's .

    UPDATE: As for why it looks to me as a bad practice, it is because I can't imagine why one's will need that. Also I think connection wrapper which will bind and unbind only once and serve as facade interface to service could be better, because it'll introduce less overhead and less error prone (in my opinion though)