为什么Eclipse开发环境会抱怨private修饰符在android Bluetooth Connecting as client ConnectThread example中无效?私人班级可以有公共成员吗?错误消息是:


类的非法修饰符
ConnectThread;仅公开,抽象,
最终版是允许的。


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

    public ConnectThread(BluetoothDevice device) {
        BluetoothSocket tmp = null;
        mmDevice = device;
        try {
            tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
        } catch (IOException e) { }
        mmSocket = tmp;
    }
    public void run() {
        mAdapter.cancelDiscovery();
        try {
            mmSocket.connect();
        } catch (IOException connectException) {
            try {
                mmSocket.close();
            } catch (IOException closeException) { }
            return;
        }
        manageConnectedSocket(mmSocket);
    }
    public void cancel() {
        try {
            mmSocket.close();
        } catch (IOException e) { }
    }
}

最佳答案

您是否单独在文件中拥有此文件?仅当它是另一个类的成员的一个类时,这才起作用。

10-08 01:44