i got a very unusual problem as my application works fine on emulator in which i’m using java socket programming to connect android device with server pc….but when i install my .apk file in my android mobile it gets crash…it does not connect with my server PC ….
please suggest some solutions why this is happening…i’m posting my socket code here…
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();
}
i have tried both way to put hostname as well as my serverIP address bt same result i get/….works fine on emulator and get crashed on device…
please reply soon..
download android terminal emulator on your device and try to ping your Pc using your pc ip address. if it got success then replace your code
InetAddress.getByName("vivek-PC")with the ip address of server PC..getHostAddress()
Hope it will help you..
if still u face any problem, then plz let me know about it.