bindService() doesn't start a second thread. If you unbind and the service is not needed, then the service's onDestroy() will be called and the next time you bind a new instance created.
If what you are trying to do is create a thread that can be used across activity instances, I would suggest not using a Service at all and just making the thread as a singleton. On Mon, Feb 13, 2012 at 12:30 PM, Dominik Thalhammer < [email protected]> wrote: > Hello, > I have the following problem: > I have an Activity which starts an second thread using > bindService(new Intent(this, MyService.class), mConnection, > Context.BIND_AUTO_CREATE); > where MyService is the Service class i want to start. > mConnection is defined as following: > private ServiceConnection mConnection = new ServiceConnection() { > public void onServiceConnected(ComponentName className, > IBinder > binder) { > s = ((MyService.MyBinder) binder).getService(); > Toast.makeText(getApplicationContext(), "Connected", > Toast.LENGTH_SHORT).show(); > } > > public void onServiceDisconnected(ComponentName className) { > s = null; > } > }; > Now i set an variable of this thread and leave the Activity using the > back button of my mobile phone. > in the onPause Routine is an call of the following function: > void doUnbindService(){ > unbindService(mConnection); > } > now when i return to my app the service is running, but my application > creates an new one, and i cant acces the old one. > I have already tried not to call doUnbindService, but this didn't > help. > Does anyone have an idea how i can get controll over the already > started Thread again ? > > Thalhammer > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

