I made a client/server socket application but only works by emulator

Asked

Viewed 1,091 times

1

I made a client/server socket application, where the client is an android device and the server is made in java. At first this all ok, in the emulator it runs correctly, but when I install the apk on the phone it does not work, it says that the application stopped.

  • It can be your network configuration. The emulator is running on the same PC (I imagine) and on localhost, that is, there are fewer barriers between them. Already on the device even the settings of your router can interfere.

  • 3

    If so, show the server and client parts of the code.

  • Your Android Manifest is asking for Internet and 3G releases?

2 answers

1

Check the Firewall is not blocking external access from your PC.
When making the connection use Asynctask because if the connection takes will give timeout in the application

0

Create an apk version that has the IP of the computer and not "localhost" in its same ip range. This way you will have to install the app on your Smartphone and have to connect on the same network as your computer, where your server is located.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.