estou com um problema, estou tentando chama o metodo sendMessagem, já com um valor certo e esta tanto erro.
public class conexao implements CommunicationListener, ConnectionListener {
private MenuPrinc menuPrinc;
private CommunicationFactory communicationFactory;
public Device device;
conexao(MenuPrinc menuPrinc) {
this.menuPrinc = menuPrinc;
}
public conexao(CommunicationFactory communicationFactory) {
this.communicationFactory = communicationFactory;
}
public void startServer() {
ServerConfiguration config = new ServerConfiguration(this);
config.setMaxNumberOfConnections(5);
communicationFactory.waitClients(config, this);
}
public void errorOnConnection(IOException e) {
System.err.println(e.getMessage());
}
public void connectionEstablished(ServerDevice device, RemoteDevice remote) {
System.out.println(remote.getBluetoothAddress());
this.device = device;
device.startListening();
device.setEnableBroadcast(true);
}
public void receiveMessage(byte[] receivedString) {
String s = new String(receivedString);
System.out.println("Recebido:"+s);
this.device.send(("echo: " + s).getBytes());
System.out.println("Echo enviado...");
}
public void sendMessage(String message) {
this.device.send(message.getBytes());
System.out.println("Enviado: "+message);
}
public void errorOnReceiving(IOException e) {
System.err.println(e.getMessage());
}
public void errorOnSending(IOException e) {
System.err.println(e.getMessage());
}
public void conecta(){
conexao server = new conexao(new RFCOMMCommunicationFactory());
server.startServer();
}
}
alguém poderia me ajuda.
Muito Obrigado.