How can I use a 3G internet connection in my Android app?

I created an application that can connect to a program that I run on the server, but it seems to work only with WiFi. When I try to use 3G, it does not establish a connection. Is there anything special I need to enable or install to use 3G?

+6
android port 3g
source share
6 answers

The problem was in the port that I used. I used 4444, but it turns out that many networks block this port. Port 1024 seems to work the most.

+1
source share

At the application level, you (usually) do not need to worry about which data connection is available for the phone.

Have you had problems, for example, when you use Wi-Fi, your web server is available, since you are hitting it from your network. Whereas this may not be available at all from the public Internet, how the 3G connection will try to connect to the server.

What error / exception do you get in 3G?

+1
source share

For what it was worth, I had the exact same problem. My application will work fine over Wi-Fi, but not over 3G. I'm on Verizon. I also used port 4444 because I thought it was the “random” port that I selected. Thanks to Verizon Wireless blocking this port, I spent more than an hour trying to diagnose my error. I switched to port 444 and now it works fine. Very frustrating. Hope this helps someone else.

+1
source share

There should be nothing extra between Wi-Fi and 3G. All I included in my manifest permissions is android.permission.INTERNET, and it works fine with either Wi-Fi or 3G, so if Wi-Fi also requires INTERNET (which I'm not quite sure since I don’t have tried JUST Wifi) and you already turned it on, I don’t know anything.

If for some reason Wifi DOES NOT require INTERNET, and this will work without it, there should be a line in the manifest like:

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 

which should provide access to the Internet (and 3G) for your phone. Sorry if this does not answer the question, but I can not think of any other reasons why 3G would be a problem when Wifi works fine. Also, make sure that you can access the network from another external location - as mentioned above, this can be a security issue that prevents external access. (Not sure if you are using 3G to connect)

0
source share

The exception that is generated when the socket is created is an IOException and a timeout (4000) is reached. When the phone is in Wi-Fi, it works fine, but when it uses 3G, the socket cannot connect to the host / port.

0
source share

You will need to check your telephone company (and good luck finding someone who can answer!) That the 3G network does not block the ports you expect to open (and are in WiFi mode). Some telecommunication blocks block almost everything that you expect (and your application stack is supposed to be available) to be standard for 3G networks (ping, telnet, RDP, etc.).

0
source share

All Articles