title: Android Shared Service?
body: <p>First of all i'd like to say two things. The first being, sorry if this question has already been asked, i've searched for similar questions around this topic but was unable to find a solution. Secondly sorry for the lengthy question, and please let me know of any error and I will be sure to make appropriate changes :).</p>
  
  <p>I am relatively new to Android development (approx 2 months), so please forgive my ignorance. The question I have is regarding the android service.</p>
  
  <p>My issue is as follows, I have created the following 3 applications:</p>
  
  <ul>
  <li>An android library which contains a small test service (<strong>myService</strong>).</li>
  <li>An application (<strong>TestApplicationOne</strong>) which has access to the android library.</li>
  <li>Another application (<strong>TestApplicationTwo</strong>) which also has access to the android library.</li>
  </ul>
  
  <p>My current solution works as follows, <strong>TestApplicationOne</strong> references the custom library and uses this library to connect to the service (<strong>myService</strong>) via the <em>bindService()</em> method. Upon connection successful the application then adds itself to a collection of observers located within <strong>myService</strong>. Each object in this collection is notified each time the service needs to broadcast a message.</p>
  
  <p>When ran, the above solution seemed to work fine. However, I now have another application (<strong>TestApplicationTwo</strong>) which would also like to use the same service as the one above. The implementation of <strong>TestApplicationTwo</strong> was created to the same workings/spec of the first application (<strong>TestApplicationOne</strong>).</p>
  
  <p>The issue I have is that when the service is started in either application, the other application is not notified of any events.</p>
  
  <p>I have tried to implement several approaches to solve this. Such as using the Singleton pattern to retain a single instance, but the problem still seems to exist. My only comprehension of this is that each time either application is started, a new instance of the library is created. Thus the library referenced in <strong>TestApplicationOne</strong> is not the same instance as the library referenced in <strong>TestApplicationTwo</strong>, and as a result, not being notified.</p>
  
  <p>Is there anybody with any experience in this issue? Or can think of any possible solution?</p>
  
  <p>Thank you in advance of any help, it is much appreciated.</p>
  
  <p>John</p>