[android-developers] Remote Service - Reconnecting

2010-08-11 Thread maecky
Hi, I have implemented a RemoteService which will increment a countere ( just for testing purposes ). Therefore I have a Task class which implements Runnable and the method run() where a infinite while loop increments the variable. From the client side, I start the RemoteService with

Re: [android-developers] Remote Service - Reconnecting

2010-08-11 Thread Mark Murphy
On Wed, Aug 11, 2010 at 9:19 AM, maecky markus.feuerst...@gmail.com wrote: How do I know if the service has already been started (therefore i would only need to bind to the service again) or not (then I would need to call startService() first and then bind to the service)? You don't know.

Re: [android-developers] Remote Service - Reconnecting

2010-08-11 Thread Markus Feuerstein
Thanks for your quick answer. If I understand right, I could solve it like this: @Override public void onStart( Intent intent, int startId ){ super.onStart( intent, startId ); if( !mServiceRunning ) { mServiceHandler = new Handler();

Re: [android-developers] Remote Service - Reconnecting

2010-08-11 Thread Kostya Vasilyev
Markus, You should match up calls to bindService() and unbindService(). If you bind to the service in your Activity's onStart(), call unbindService in onStop(). Next time your activity is started, it will call bindService() again. Service lifecycle is managed by Android, and the service

Re: [android-developers] Remote Service - Reconnecting

2010-08-11 Thread Mark Murphy
On Wed, Aug 11, 2010 at 9:50 AM, Markus Feuerstein markus.feuerst...@gmail.com wrote: Thanks for your quick answer. If I understand right, I could solve it like this:     @Override     public void onStart( Intent intent, int startId ){         super.onStart( intent, startId );         if(