How to communicate between Android Services and Activities
<p>I'm working on a little android project for communication between the internet and the phone. To do so, I've written a basic NetworkManager-Class which does all the connection related things. This Class should run as a service, so that the phone always can listen on incoming ports and so on. The basic structure should look like:</p>

<p>AndroidApplication -> (uses) NetworkManager --> (is-a) Service.</p>

<p>Now I read about the lifecylce of android services and I as far as i understand, I should only use the onCreate()-Method instead of the real c'tor. But I need this c'tor do define a port to be listen on and to give my NetworkManager the current Application-Context. </p>

<p>Also I need to communicate between the Service and the App in both directions I think. The App should be able to ask the NetworkManager about new incoming packages.
(So I need a communication App -> NetworkManager)</p>

<p>And I would like to be able to print a status message in the status field, so that the user can click on it and the app is loaded. As far as I got this, I would be best, if I implement the status message in my NetworkManager.(e.g. when you got a WhatsApp-Message, this is printed in the status field and as soo as you click on it, it WhatsApp is started)
(So I need a communication NetworkManager -> App)</p>

<p>I searched quite a bit around this topic, and currently I have my App instantiating a object of my NetworkManager-Class (calling its "normal" c'tor) and then doing some busy waiting . Now I'm not sure, how I really start the service. I read about intents on android, but didn't really got how this is working. So my question:</p>

<ul>
<li>How do I start a service (with possible more parameters given in the c'tor of the service class) and how can I communication with it in both directions?</li>
<li>Also I read, that android can start services at boot time. Sadly I need an application context (for SQLite-Database) to start my NetworkManager-Service. So I think I won't be able to start this service without starting the whole app once at boot time, will I?</li>
</ul>

<p>Thanks for reading and greetings</p>

<p>Pille</p>
