My application receives a string from server and it is compared directly with the value that was send by the server. But it does not enter into the if block. The part of my code with the issue is
public void reciever(){
new Thread(new Runnable() {
@Override
public void run() {
try {
Socket s = new Socket("192.168.0.105",6000);
InputStream in=s.getInputStream();
final byte[] recv=new byte[10];
in.read(recv);
final String back=new String(recv,StandardCharsets.UTF_8);
s.close();
descr=back+"spacecheck";
if(back.equals("Psoriasis")){
descr="plaque: thick red patches of skin guttate: small red spots on the torso, limbs, face, and scalp inverse: a red, shiny, smooth rash in skin folds pustular: white pustules surrouned by red skin";
}
if (back.equals("Cold Sore")){
descr="red, fluid-filled blisters that appear near the mouth your lips will often tingle or burn before the sore is visible the sore is painful or tender to the touch,12 days";
}
if(back.equals("Rubeola (Measles)")){
descr="fever, cough, and runny nose reddish-brown rash spreads down the body three to five days after first symptoms appear tiny red spots with blue-white centers inside the mouth,1 week";
}
mine.post(new Runnable() {
@Override
public void run() {
prg.setProgress(100);
tx.setText(back);
AlertDialog.Builder shower = new AlertDialog.Builder(MainActivity.this);
shower.setTitle(back);
shower.setMessage(descr);
shower.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = shower.create();
alert.show();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
I copy pasted the value send from my server and also the dialogue box shows the value exaclty as i put in the server and also in the if code. The three if statements shows the same issue. I also made sure no extra space is in the 'back' variable. what i'm i missing bros?
Aucun commentaire:
Enregistrer un commentaire