How can I use a 3G internet connection in my Android App?
Asked Answered
C

6

6

I have made an App that can connect to a program that I am running on a server, but it only seems to work with WiFi. When I try to use 3G it doesn't make the connection. Is there something special that I have to turn on or set in order to use 3G?

Concede answered 13/5, 2010 at 13:31 Comment(0)
C
1

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

Concede answered 11/9, 2010 at 19:42 Comment(1)
Where to find that port or how to change its value?Thievery
A
1

At the application level you (normally) don't have to worry about what data connection is available to the phone.

Have you looked into problems such as when you use WiFi you web server is accessible since you are hitting it from within your network. Whereas, it may not be accessible at all from the public internet which is how the 3G connection will be trying to connect to the server.

What error / exception do you get on 3G?

Adaadabel answered 13/5, 2010 at 13:49 Comment(0)
C
1

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

Concede answered 11/9, 2010 at 19:42 Comment(1)
Where to find that port or how to change its value?Thievery
N
1

For what it's worth I was having the same exact problem. My app would work perfect over WiFi but not over 3G. I am on Verizon. I was also using port 4444 because I thought it was a "random" port I had chosen. Thanks to Verizon Wireless blocking this port I spent over an hour trying to diagnose my error. I switched to port 444 and it works fine now. Very frustrating. Hopefully this will help someone else.

Niela answered 6/11, 2010 at 22:12 Comment(0)
Z
0

There shouldn't be anything additional between Wifi, and 3G. All I've included in my Manifest Permissions is android.permission.INTERNET, and that works fine with either Wifi or 3G, so assuming INTERNET is required for Wifi as well (which I'm not entirely sure about, since I haven't tried JUST Wifi) and you've already included it, I don't know of anything else.

If by some chance Wifi does NOT require INTERNET, and it happens to work without it, the Manifest should include a line like:

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

which should grant internet (and 3G) access for your phone. Sorry if that doesn't answer the question, but I can't think of any other reason 3G would be an issue when Wifi works fine. Additionally, make sure you can access the network from another outside location--as said before me, it may be a matter of security preventing outside access somehow. (Not sure what you're using 3G to connect to)

Zollie answered 13/5, 2010 at 22:4 Comment(0)
K
0

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

Kipton answered 13/5, 2010 at 22:57 Comment(0)
C
0

You'll have to check with your phone company (and good luck in finding someone who can answer!!) that the 3G network doesn't block ports that you're expecting to be open (and are when in WiFi mode). Some telcos block almost everything you'd expect (and your app stack assumes to be available) to be standard on 3G nets (ping, telnet, RDP etc., etc.).

Casper answered 4/8, 2010 at 12:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.