为什么Eclipse开发环境报错android中的private修饰符无效Bluetooth Connecting as client ConnectThread example ?私有(private)类(class)可以有公共(public)成员吗?错误信息是:
Illegal modifier for class ConnectThread; only public, abstract, and final are permitted.
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) { }
}
}
最佳答案
你有这个单独的文件吗?仅当一个类是另一个类的成员时,这才有效。
关于java - Android 蓝牙 ConnectThread 示例错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5265750/