i am working on a application in which the application has to connect to the java class using socket programming. The application is working fine in the android emulator but it is not working on my device. There is no socket connectivity between my device and computer when i run it on my device. I am including some of my code for socket connection here please check and suggest me some solutions. its urgent..!!
try {
socket = new Socket(InetAddress.getByName("vivek-PC")
.getHostAddress(), 8888);
dataOutputStream = new DataOutputStream(socket.getOutputStream());
dataInputStream = new DataInputStream(socket.getInputStream());
} catch (UnknownHostException e) {
// textIn.setText("Button Clicked" + e);
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
well i think you should first check the connection between your device and ur server-PC by installing android terminal emulator app on ur device and ping it with your server ip address…..then try to connect your device with server…hope u’ll succeed….