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
 Hi

I have been looking at the ConnectivityManager class documented at
 http://developer.android.com/reference/android/net/ConnectivityManager.html 
.

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
 http://developer.android.com/reference/android/net/ConnectivityManager.html #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
Thanks
Graeme
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How can I find out if I read the GPS signal

As part of an application for registrer whether a vehicle can pass the
next traffic light without having stop for red light, I am trying to
get the GPS Location.

So far I have tried the code below, but the HTC Tattoo telephone keeps
stopping the application.
The reason is that the List providers remains empty.

Is there any way that I can extend my code, so I can understand why
providers remains empty.
I know I get a NullPointerException, but I don't know why as GPS is
enabled.

I will really appreciate your help on how to get
- status of the GPS
- content of providers.

The code is listed below (I don't get any compilation errors):

protected void onResume() {
        List providers;
        final String tag = "readdata";

        super.onResume();

        locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
        providers = locationManager.getProviders(true);

        if (!providers.isEmpty()) {
         location = locationManager.getLastKnownLocation((String)
providers
            .get(0));
         locationManager.requestLocationUpdates((String)
providers.get(0),
             15000, 1, this);
         }
         GeoPoint p = new GeoPoint((int) (location.getLatitude() * 1E6),
            (int) (location.getLongitude() * 1E6));


             mc.animateTo(p);
             mc.setZoom(17);
             mapView.setSatellite(true);
             mapView.setStreetView(true);
             mapView.invalidate();

    }

-- 

2. Tiled bitmap gets distorted?

I created a bitmap to fill in some empty area on my toolbar. I want it
to tile as it expands.

<?xml version="1.0" encoding="UTF-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/map_toolbar_background"
    android:gravity="top"
    android:tileMode="repeat" />

My problem is, that placed next to buttons created with the same
background, of the same height, it looks wrong. It gets distorted and
stretched some vertically and is blurrier than the buttons which are
not tiled. If I use the same bitmap just as a android:background, it
looks perfect.

Any ideas what android's doing to my bitmap?

-- 

3. sending lists from a server to client (android)

4. NexusOne lifecycle issues, continued

5. add calendar_alerts error.

6. SOLD OUT!!UPDATED WTS: Simpati TURBO (nutrisi murah meriah untuk HP Android)

7. killpg implementation missing in bionic signal.h