Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method undefined: manageConnectedSocket()

We want to remote a roboter via Bluetooth. Now we are using the android example. we want to connect as client. The code before this part is working. Now we get an error at:

manageConnectedSocket(mmSocket);

"The method is undefined". What can we do to solve this problem ? Thanks for answers.

private class ConnectThread extends Thread {
    private final BluetoothSocket mmSocket;
    private final BluetoothDevice mmDevice;

    public ConnectThread(BluetoothDevice device) {
        // Use a temporary object that is later assigned to mmSocket,
        // because mmSocket is final
        BluetoothSocket tmp = null;
        mmDevice = device;

        // Get a BluetoothSocket to connect with the given BluetoothDevice
        try {
            // MY_UUID is the app's UUID string, also used by the server code
            tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
        } catch (IOException e) { }
        mmSocket = tmp;
    }

    public void run() {
        // Cancel discovery because it will slow down the connection
        mBluetoothAdapter.cancelDiscovery();

        try {
            // Connect the device through the socket. This will block
            // until it succeeds or throws an exception
            mmSocket.connect();
        } catch (IOException connectException) {
            // Unable to connect; close the socket and get out
            try {
                mmSocket.close();
            } catch (IOException closeException) { }
            return;
        }

        // Do work to manage the connection (in a separate thread)
        manageConnectedSocket(mmSocket);
    }

    /** Will cancel an in-progress connection, and close the socket */
    public void cancel() {
        try {
            mmSocket.close();
        } catch (IOException e) { }
    }
}
like image 382
Maximilian Ast Avatar asked Sep 17 '26 23:09

Maximilian Ast


1 Answers

According to this, manageConnectedSocket doesn't exist.

manageConnectedSocket() is a fictional method in the application that will initiate the thread for transferring data, which is discussed in the section about Managing a Connection.

And you haven't defined it in your code. You need to create the method yourself, or follow the rest of the Android tutorial.

like image 164
David B Avatar answered Sep 22 '26 12:09

David B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!