• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Not detecting incoming connection Bluetooth

Hi,

I am developing a bit with bluetooth, unfortunately my application don't detecting incoming connections. Here's my code:

Code:
private class AcceptThread extends Thread {
    private final BluetoothServerSocket mmServerSocket;
 
    public AcceptThread() {
        // Use a temporary object that is later assigned to mmServerSocket,
        // because mmServerSocket is final
        BluetoothServerSocket tmp = null;
        try {
            // MY_UUID is the app's UUID string, also used by the client code
            tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
        } catch (IOException e) { }
        mmServerSocket = tmp;
    }
 
    public void run() {
        BluetoothSocket socket = null;
        // Keep listening until exception occurs or a socket is returned
        while (true) {
            try {
                socket = mmServerSocket.accept();
            } catch (IOException e) {
                break;
            }
            // If a connection was accepted
            if (socket != null) {
                // Do work to manage the connection (in a separate thread)
                manageConnectedSocket(socket);
                mmServerSocket.close();
                break;
            }
        }
    }
 
    /** Will cancel the listening socket, and cause the thread to finish */
    public void cancel() {
        try {
            mmServerSocket.close();
        } catch (IOException e) { }
    }
}
it blocks on "socket = mmServerSocket.accept();".
I am using the following UUID:
private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");

the SDP name can be arbitrary according to the documentation.

I have tried to transfer files between my computer and my android phone and between my nokia symbian phone and my android phone and always i receive data by default and not with my program.

Can someone help me out ?
 
Back
Top Bottom