Can I force Android to open a network connection on a specified network interface/network type ?

by Graeme » Fri, 06 Mar 2009 19:37:59 GMT

Sponsored Links

I have been looking at the ConnectivityManager class documented at 

I would like to know if an Android application can open a network
connection (socket) on a specified network interface [on a device
supporting multiple network interface types WiFi, Cellular, WiMax
etc] ? I am looking for the capability for an application to open a
socket on a given type of network for example
over WiFi network or over 3G Cellular Data network.

If this is possible in Android, how would I code this requirement
within the API Framework ?
The ConnectivityManager enables an application to learn about
available network connections and
currently categorises them as either TYPE_WIFI or TYPE_MOBILE.

There is a member function in the ConnectivityManager class  called
requestRouteToHost(int,int) [see #requestRouteToHost(int,%20int)]
which "Ensure that a network route exists to deliver traffic to the
specified host via the specified network interface. An attempt to add
a route that already exists is ignored, but treated as successful."
Sounds like this would install an IP routing table entry to reach a
given host via a specified network interface type (WiFi or Mobile).
After calling this would it be sufficient for an application to open a
socket and connect to the desired destination address ?

Or perhaps the application needs to bind() a socket to a local address
of a network interface of the desired type (WiFi or Mobile)

Or by setting a socket-level socket option of SO_DONTROUTE ?

Any help would be appreciated

Other Threads

1. Android sdk 1.5 always got No Service

Hi all
    I had install SDK 1.5 and setup AVDs on My windows XP. All these
things got done successfully. But after I start the emulator up, it
seems GSM modem has not started and got No Service. Would you like to
let me know how to fix it? Do emulator require Internet connection as
I had no broad band internet connection now?

2. video recording in 1.5

is video recording supported in 1.5?

i got it mostly working with the Haykuro 1.5 ADP image - the video 
file was legally formatted but didn't play properly.

with yesterday's official 1.5 images, it doesn't work at all. 
setVideoEncoder() fails, with the wonderfully informative error 
message "setVideoEncoder failed".

thanks for a position on this,


3. New Sensors

4. How to create a Toast from a background operation?


6. ListView display problem

7. The state of the "Android" trademark..