Can android do "waitForResponse"
<p>I am developing an application to communicate with a device via bluetooth.
Same as the BluetoothChat sample, my application makes a service object, and call service.connect() to get a connectedThread for data transmission.</p>

<p>and I have a command method, which takes an integer as its parameter.</p>

<p>the problem is, sometimes, that device returns invalid data.
So when I want to execute the command with ten different parameter, I need to do something like :</p>

<pre><code>for (i = 0; i &lt; 10; i++) {
    myService.write(command(i)); 
    packet = waitForResponse(myService);

    if (packet is valid) {
        do something;
    } else {
        i--;
    }  
}
</code></pre>

<p>My program is using handler to deal messages, e.g. when the connectedThread read some data, it will</p>

<pre><code>mHandler.obtainMessage(ControlActivity.MESSAGE_READ, -1, -1, data)
                         .sendToTarget();
</code></pre>

<p>And there is a handler in my Activity class to deal with these messages.</p>

<p>How can I do something like "waitForResponse" on Android?
or Is there any other way to meet my requirement?</p>

<p>API Level: 13</p>
