简体   繁体   English

在 flutter 应用程序中同时使用 Wifi 和 mobile.network

[英]Using both Wifi and mobile network at the same time in flutter app

In my flutter app, I need to get information from a device via wifi as a stream. Also I need to keep my google maps online via Mobile inte.net.在我的 flutter 应用程序中,我需要通过 wifi 从设备获取信息,如 stream。我还需要通过 Mobile inte.net 保持我的谷歌地图在线。 How can I use both wifi and mobile.network at the same time in my phone.如何在我的手机中同时使用 wifi 和 mobile.network。 I made a lot of search but I can't find any solution for this.我进行了大量搜索,但找不到任何解决方案。

I don't think it's possible.我不认为这是可能的。

The phone would need two network antennas and possibly two network adapters.电话需要两个网络天线,可能还需要两个网络适配器。
You can surely toggle both wifi and mobile data at the same time and they can probably switch frequently to optimize your connection or send requests to different services.您当然可以同时切换 wifi 和移动数据,它们可能会频繁切换以优化您的连接或向不同的服务发送请求。
But you can't really use them both at the same time.但是你不能真正同时使用它们。
(if it's possible) I don't recommend it, since a majority of phones will not support this feature since you need two network antennas. (如果可能的话)我不推荐它,因为大多数手机不支持此功能,因为您需要两个网络天线。

From the facts as presented, there are a couple of possible solutions, but they aren't perfect and I'm guessing on one as I haven't tested it yet.从所提供的事实来看,有几个可能的解决方案,但它们并不完美,我猜测其中一个,因为我还没有测试过。

One, Google Maps has an offline mode.第一,谷歌地图有离线模式。 You can set it up to download maps for offline use.您可以将其设置为下载地图以供离线使用。 It will show your position on the maps whether you are connected to the inte.net or not, but you won't get traffic data or accurate travel times.无论您是否连接到互联网,它都会在地图上显示您的 position,但您不会获得交通数据或准确的旅行时间。 Not great, but it can work.不是很好,但它可以工作。

Two, it is possible for a phone to have a WiFi.network and Cellular.network active at the same time, but not in the way everyone seemed to think.第二,一部手机有可能同时激活 WiFi.network 和 Cellular.network,但并不是每个人都认为的那样。 Since you are wanting the cellular connection open to have access to the inte.net, I'm assuming this is because the WiFi.network you want to access doesn't have the inte.net.由于您希望打开蜂窝连接以访问 inte.net,我假设这是因为您要访问的 WiFi.network 没有 inte.net。 So, reverse the WiFi.network.因此,反转 WiFi.network。 Setup your phone to be a hotspot.network, it runs its own WiFi.network while maintaining access to the inte.net through its cellular.network.将您的手机设置为 hotspot.network,它运行自己的 WiFi.network,同时通过其 cellular.network 保持对 inte.net 的访问。 I'm guessing here, but unless phones have some specific security protocol forbidding it I don't know about (which can be the case), your app should be able to contact anything connected to its phone's WiFi while still having access to the inte.net.我在这里猜测,但除非手机有一些我不知道的特定安全协议禁止它(可能是这种情况),否则您的应用程序应该能够联系连接到其手机 WiFi 的任何东西,同时仍然可以访问互联网。网。

If this doesn't work for some reason, you can try a trick I used when I set up a car office.如果由于某种原因这不起作用,您可以尝试我在设置汽车办公室时使用的技巧。 Get a mobile hotspot device.获取移动热点设备。 It's a device you can put a cellular SIMM in and it creates a WiFi hotspot.这是一种可以放入蜂窝 SIMM 并创建 WiFi 热点的设备。 You can connect to it, along with other devices in the car.您可以连接到它,连同车内的其他设备。 All will being using WiFi and the hotspot will provide the inte.net access.所有人都将使用 WiFi,热点将提供互联网访问。

If what you are connected to can only create a WiFi.network for you to access and it can't be configured to connect to one itself, you could technically still be able to do it by.network switching.如果您所连接的设备只能创建一个 WiFi.network 供您访问,并且无法配置为连接到 WiFi.network 本身,那么从技术上讲,您仍然可以通过 .network 切换来完成。 Much harder to do (probably impossible on some devices) and will likely mess with other apps depending on inte.net access, so a real break glass in case of emergency type of situation there.更难做到(在某些设备上可能是不可能的)并且可能会根据 inte.net 访问与其他应用程序混淆,因此在出现紧急情况时真正的破玻璃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM