我可以支持Wi-Fi和蜂窝网络接口在同一时间对Android开放?蜂窝、接口、时间、在同一

2023-09-05 01:58:13 作者:颜无敌

我的工作将运行在手机上的应用,其中手机 将是一个私人的Wi-Fi网络上的一个站。这款手机将是一个 站,而不是接入点,私人无线网络连接的网络不 路由到互联网。我的应用程序需要与沟通 当地的Wi-Fi网络在Internet上的服务器和设备, 所以它需要有两个网络上连接在同一时间。 我一直在试图找出如何做到这一点。

I'm working on an application that will run on a phone where the phone will be a station on a private Wi-Fi network. The phone will be a station, not an access point, and the private Wi-Fi network does not route to the Internet. My application needs to communicate with servers on the Internet as well as devices on the local Wi-Fi network, so it needs to have connections on both networks at the same time. I've been trying to figure out how to do this.

我一直在讨论中描述的技术 谷歌Android开发组题为灿 安卓2.X连接到3G和Wifi数据网络同步?,但 它都不尽如人意。我觉得是这样的,当我启用 通过调用蜂窝网络 ConnectivityManager.setNetwork preference(ConnectivityManager.TYPE_MOBILE), 我有打开的插槽上的Wi-Fi网络上的关闭。我没有 试了一下,但我怀疑同样的事情也会发生在插座 当我切换到Wi-Fi蜂窝网络。

I've been trying the technique described in the discussion on the Google Android developers group titled "Can Android 2.X connect to 3G and Wifi data networks simultaneously?", but it is not working well. What I find is that, when I enable the cellular network by calling ConnectivityManager.setNetworkPreference(ConnectivityManager.TYPE_MOBILE), any sockets I have open on the Wi-Fi network are closed. I haven't tried it, but I suspect the same thing will happen to sockets on the cellular network when I switch back to Wi-Fi.

的另一个问题是, 这些电话在全球范围内进行操作,更改网络设置 对于整个电话,而不仅仅是应用。切换网络 建立全球像这样将与其他应用程序干扰的 恰好是在手机上运行。即使在我的应用程序退出, 手机继续用它设置的最后一个网络配置中运行。

Another problem is that, these calls operate on a global level, changing the network settings for the entire phone, not just the application. Switching the network set up globally like this will interfere with any other app that happens to be running on the phone. Even after my application exits, the phone continues to run with the last network configuration it set.

我在寻找一种方式让连接双方的手机开放 数据和Wi-Fi网络的同时,并没有与干扰 在手机上运行的其他应用程序。

I'm looking for a way to have connections open on both the cellular data and Wi-Fi networks at the same time, and without interfering with other applications running on the phone.

1.Does任何人都知道该怎么做 这个问题 2.Does谁知道这是否可能?

1.Does anyone know how to do this? 2.Does anyone know if this is possible?

感谢您的帮助。

推荐答案

这线程Android:部队要发送的数据通过无线电VS无线提到了两种可能的方法的问题。

This thread Android: Force data to be sent over radio vs WiFi mentions two possible approaches to the problem.

只要你想你的应用程序使用一个特定连接设置网络preference:

Set the network preference whenever you want your app to use a specific connection:

ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
cm.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);

启用高优先级的移动数据连接:

Enable high priority mobile data connection:

connectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableHIPRI");

有关它明确说明它的工作原理与Android 2.2的第二个办法,不知道这是否正常工作实际版。但据我发现, enableHIPRI 或多或少是一个隐藏的网络设置,所以我会preFER第一种方法,如果可能的。

For the second approach it is specifically stated it works with Android 2.2, no idea if this works in actual versions as well. However as far as I found out, enableHIPRI is more or less a hidden network setting, so I would prefer the first method if possible.

 
精彩推荐
图片推荐