views:

1407

answers:

1
+1  A: 

Your client will never discover the server if the server is not actually discoverable. Your server code's comment says "Make sure the device it discoverable," but listening on a socket does not mean the device is discoverable. You can make the server discoverable by calling:

Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);

This is an Intent because discoverability must be enabled by the system and only with approval from the user (so this will raise a dialog, requesting discoverability for 300 seconds). Only during this window of 300 seconds will the server actually be discoverable. During this time, your client code should work just fine and you'll get the pairing requests.

This is all covered in detail in the Android dev guide: http://developer.android.com/guide/topics/wireless/bluetooth.html

Scott Main
I do use that code, I just put the comment there for brevity. I was trying to make the code snippet smaller.
CaseyB
I'll update my code to be more complete.
CaseyB