0


I'm curios if an Android device has both connections configured/available ConnectivityManager.TYPE_MOBILE & ConnectivityManager.TYPE_WIFI how it choose which connection to use for http requests?
Imagine I'm somewhere in WiFi zone without Internet access available (or requires login) but still i could connect to the Internet using GPRS/EDGE etc. (I mean MOBILE).
How Android handles such situations or how to handle it manually?
Making http requests is simple like:

HttpClient httpclient= new DefaultHttpClient();
HttpResponse response = httpclient.execute(mHttpRequest);

but there is nothing about which connection to use or force 2 use...

Stan
  • 6,511
  • 8
  • 55
  • 87

1 Answers1

2

Check the answer here:

How to use 3G Connection in Android Application instead of Wi-fi?

Basically, you use ConnectivityManager's methods to route the connection. Try it with a test application that requests a GSM connection when WiFi is available and check whether it will do.

Community
  • 1
  • 1
Kamen
  • 3,575
  • 23
  • 35
  • So i need to implement such method manually. If my app requires Internet access to run It Looks like I have to monitor connection state additionally. A mean while app is running user could move and connect to some WiFi zone with free Internet access so it's better to use it (while it's available) instead of mobile... Its not an easy task as i c... – Stan May 29 '11 at 18:16
  • Also check DownloadManager class - it does all monitoring for you. The bad news - it's for Android >=2.3 – Kamen May 29 '11 at 21:54