onDestroy, killing a running thread
<p>I have a method like this in my class which extends <code>Activity</code></p>

<pre><code>@Override
public void onDestroy() {
    Log.i("onDestory: ", "Inside OnDestory!");
    bluetoothCommunicator.destroyedApp();
    super.onDestroy(); 
}
</code></pre>

<p>The method <code>destroyedApp()</code> look like this:</p>

<pre><code>public void destroyedApp() {
        if(server != null)
            server.destroy();   
}
</code></pre>

<p>Where <code>server</code> is an Instance of a class which extends <code>Thread</code></p>

<p>Here is the scenario: </p>

<p>I'm opening the application for the first time, inside my <code>onCreate</code> method, I create a new instance of the bluetooth class which sets up the <code>BluetoothServerSocket</code>, this works fine and I'm able to transfer files to my phone. </p>

<p>This also works when I have my application in the background, because the thread is still alive. </p>

<p><strong>But</strong></p>

<p>When I'm killing the application, according to the <code>Activity Life Cycle</code></p>

<p><img src="http://i.stack.imgur.com/kyp7E.png" alt="Activity Life Cycle here"></p>

<p>The <code>onDestroy()</code> method should be called by the Android Framework. And when I'm launching the application once more, the <code>onCreate</code> method should be called, but it doesnt seems that an instance of the <code>BluetoothServerSocket</code> is being created. I have no <code>LogCat</code> info, because the device which sends the bluetooth file, only says: </p>

<pre><code>Error Log:
Write Error: 
Transport endpoint is not connected
__obex_connect:
error=-2
Unable to connect to the server
Error
</code></pre>

<p>Which tells me that the <code>BluetoothServerSocket</code> is not "alive" </p>

<p>Any suggestion on how I can accomplish this?</p>
