Strange behaviour of onResume() - Thread already started
<p>I've got a class which replicates the Bluetooth OBEX Protocol. This class is based on the Bluetooth Chat Example. An instance of this class is constructed in my <code>onCreate()</code> method</p>

<pre><code>bluetoothCommunicator = new BluetoothCommunicator(BaseClass.this); 
</code></pre>

<p>This <code>BluetoothCommunicator</code> class has two inner classes which extends Thread</p>

<p><code>AcceptThread</code> and <code>ReadInputThread</code></p>

<p>From my baseClass where the communication socket is initialized, I also have the <code>onResume()</code> and the <code>onPaused()</code> methods. </p>

<pre><code>@Override
public void onResume() {
     bluetoothCommunicator.resumeCommunicator();    
}
</code></pre>

<p>This will call the resumeCommunicator method: </p>

<pre><code>public void resumeCommunicator() {
        Log.i("RESUME COMMUNICATOR: ", "COMMUNICATOR IS RESUMED");
        if(server == null)
            Log.i("Server: ", "IS NULL"); 

        if (server == null) {
            AcceptThread server = new AcceptThread();
            server.start();
        }

        if(!server.isAlive()) {
            server.start();
        }
    }
</code></pre>

<p>In this method, <code>server</code> is an instance of <code>AcceptThread</code></p>

<p>But this <code>onResume</code> method will cause some problems for me. When I put my application in the background, and tries to open it again, the <code>onResume</code> method is called, but it says that the Thread already has started, and throws an exception. It sounds pretty strange that this would happend, by just looking at the code in the <code>resumeCommunicator</code> method.  </p>
