Is it possible to force network traffic through Wifi or the TMobile network?

纵饮孤独 提交于 2019-12-06 22:31:42

问题


I'm wondering if, with the G1, it's possible to force the network traffic to pass through the Wifi or through the Cell GSM network. I need to force an application to connect through the tower network to get some login information. Is this possible? Anyone have any ideas as to how this would be possible? I'm trying to accomplish this inside an app with the Android SDK (Sorry I wasn't more clear about that originally)


回答1:


It turns out to be possible using the WifiManager object to disable and then re-enable the connection. You can block it for the duration of a network call if you want to force data over the cell network. I imagine there is a similar GSM network manager out there which will do a similar task for the cell connection.




回答2:


I'm assuming that you can simultaneously communicate via either channel, so at some level there aught to be separate network interfaces for each. Since android is based on linux, you could try using ifconfig or a library function to determine which interfaces are available, and which does what. If you can accomplish this, there should be a way to explicitly send/recv via the channel you want (i.e. by communicating via the ip for that interface).

Sorry I couldn't be more specific.




回答3:


What you are looking for on the G1 is to set the default route. You may do so using the linux utility aptly named route, the default route is going to be to ip 0.0.0.0 and then the gateway.

Not sure if you can do this per application, but you can do it system wide!



来源:https://stackoverflow.com/questions/604535/is-it-possible-to-force-network-traffic-through-wifi-or-the-tmobile-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!