RE:Busco programador J2ME
Lo que hago exactamente es en la misma función mandar el valor de "@" para que este me responda. Enviar, si que lo envía, pero no recibo nada. ¿Ves algún error en el código?, ¿sabes que estoy haciendo mal?
public void Mensaje(String msg){
try{
StreamConnection con = (StreamConnection)Connector.open("btspp://0008F4A0008E:1;authenticate=false;encrypt=false;master=false");
DataOutputStream out = con.openDataOutputStream();
DataInputStream in = con.openDataInputStream();
//Escribimos datos en el stream
out.writeUTF("@");
Thread.sleep(500);
// Leemos la respuesta
byte[] data = null;
try
{
int length = in.read();
data= new byte[length];
length = 0;
while (length != data.length)
{
int ch = in.read(data, length, data.length - length);
if (ch == -1)
{
throw new IOException("Imposible leer");
}
length += ch;
}
}
catch (IOException e)
{
System.err.println(e);
}
Alert alerta = null;
alerta.setTimeout(Alert.FOREVER);
alerta = new Alert("PRUEBA", data+" " , null, AlertType.ERROR);
display.setCurrent(alerta);
in.close();
out.close();
con.close();
}
catch(Exception e){
mostrarAlarma(e, c, 0);
}
}