0
In an Android application, I have a java socket client that sends integers (using writeInt) to a socket server on Android that I’m trying to read these integers. I receive correct strings but I cannot convert when using parseint, Here and Here.
In this piece of the code I try to read using read(), however always returns zero, I have translated the several return containing integer but could not intender, if someone with experience can help and tell which method is used to read the integer...
conexao = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader( conexao.getInputStream() ));
clientSentence = inFromClient.read(); //retorna zero
Bundle b = new Bundle();
b.putInt("resposta", clientSentence);
rr.send(1, b);
} catch(Exception e ){
}
Reading this question, and the other two, I think it would be better if you made your project available, or a part that can be executed (e.g. on github), so that we can try to reproduce the problem.
– mari
Articuno, actually in this question : https://answall.com/questions/243414/converter-string-para-integer-android/243416#243416 ; I ask someone to test the code: "If one can test and see why the conversation is not successful, or if one already knows the problem by looking at the code and can identify, the codes are following", then... Something else You would know which reading method to use to read the integer directly, in the read method of the bufferedReader class did not intend well, The conversation of the received string only returns zero or nothing, that I tried last,
– Aislan Silva Costa