No - you should not setNetworkPreference.  That just ranks the different
default-routable networks so we prefer one over the other (like the current
default of using wifi over 3g if wifi is available).

You are correct that bringing up HIPRI doesn't make it take priority over
mobile data (or wifi).  However when you add the host route on the HIPRI
interface that does take priority for that particular address.

startUsingNetworkFeature followed by requestRouteToHost should do the
trick.  Right after the requestRouteToHost try getting a bugreport and look
at the route table.

It's possible that your particular android device doesn't do
requestRouteToHost correctly - it's not widely used.

I'm interested in this problem - if you want you can send me a tcpdump and
bugreport and I can take a look.

R

On Wed, May 2, 2012 at 5:39 AM, Jason Teagle <[email protected]> wrote:

> I've come into this thread late, but from reading the code you present and
> the docs, combined with my suspicious mind, it's leading me to think this:
>
> You ask for the system to use HIPRI over TYPE_MOBILE, which it says it
> grants. But I can't see anything in the docs that suggests that this takes
> priority over *all* other types of network routes. It suggests that *if*
> the system were to use TYPE_MOBILE for comms, *then* it would use HIPRI -
> but if it decides to use TYPE_WIFI instead, then your calls are having no
> effect.
>
> An analogy would be changing current directories on Windows from the
> command prompt. If you open the prompt, you are most likely going to be at
> C:\Users\MyLogin (on Windows 7) or something like that.
>
> If you type cd D:\SomeSubDir it accepts it. But if you then type dir, you
> get the files from your own users directory - not the D directory.
>
> If you now type d:, and then dir, *now* you get the files on the D
> subdirectory you changed to.
>
> In other words, despite asking for a route to SomeSubDir over the D
> 'network', we were still on the 'C' network effectively.
>
> My point (there was always hope I was getting to one) is that as far as
> the device is concerned, you've created a route over TYPE_MOBILE / HIPRI,
> but TYPE_WIFI is still an option and it chooses to use it.
>
> Is it possible that setNetworkPreference(TYPE_**MOBILE) is the last piece
> of the puzzle?
>
> (Inspired by this article: http://stackoverflow.com/**
> questions/2513713/how-to-use-**3g-connection-in-android-**
> application-instead-of-wi-fi<http://stackoverflow.com/questions/2513713/how-to-use-3g-connection-in-android-application-instead-of-wi-fi>
> )
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to 
> android-developers@**googlegroups.com<[email protected]>
> To unsubscribe from this group, send email to
> android-developers+**[email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to