Java – how to bind this service in Android?
This is the code in my activity Start the intention and connect, right?
hello_service = new Intent(this,HelloService.class); hello_service_conn = new HelloServiceConnection(); bindService( hello_service,hello_service_conn,Context.BIND_AUTO_CREATE);
But my question is... What's in the connection?
class HelloServiceConnection implements ServiceConnection { public void onServiceConnected(ComponentName className,IBinder boundService ) { } public void onServiceDisconnected(ComponentName className) { } };
Can someone tell me the code I put in onserviceconnected and onserviceconnected?
I just want a basic connection so that my activities and services can communicate with each other
Editor: I found a good tutorial. I can actually close this question unless someone wants to answer it http://www.androidcompetencycenter.com/2009/01/basics-of-android-part-iii-android-services/
Solution
I would like to point out that if you follow the service example provided by Google, your service will leak memory. Please refer to this excellent post on how to execute correctly (and vote for relevant Google errors)
http://www.ozdroid.com/# ! BLOG/2010/12/19/How_ to_ make_ a_ local_ Service_ and_ bind_ to_ it_ in_ Android