I making android applicaton and i have java.lang.NullPointerException with this code. Java server is on the comuter. Thanks for help.
try {
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Socket socket;
socket = new Socket("192.168.0.179", 5450);
os = new PrintStream(socket.getOutputStream());
is = new DataInputStream(socket.getInputStream());
in = is.readLine().trim();
if(in == "hello") {
os.print(edit.getText().toString());
os.flush();
Log.d("LoL", in);
Log.d("LoL", edit.getText().toString());
in = is.readLine().trim();
edit.setText(in);
os.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
} catch (Exception e) {
Log.d("LoL",e.toString());
}