Windows Phone 7后台代理中的网络访问

发布于 2025-01-02 11:09:49 字数 659 浏览 2 评论 0原文

我有一个应用程序,它使用后台代理通过 wi-fi(而不是蜂窝网络)访问网络和本地网络。当手机锁定时,后台代理运行时 Wi-Fi 网络不可用 - 至少在 Samsung Focus Flash 手机上是这样。我还有一部较旧的 LG Quantum 手机,当后台代理运行时,它似乎工作正常 - 至少在插入电源时。我现在正在尝试不插入电源,看看这是否是行为差异的原因。

(更新:如果三星 Flash Focus 已插入(充电),它还会在后台代理启动时提供 wi-fi 访问,因此这解释了三星和 LG Quantum 之间的行为差​​异。

所以,现在剩下的唯一问题是“当后台代理启动且未插入时,如何强制手机打开 Wi-Fi?”)

我使用方法 NetworkInterface.GetIsNetworkAvailable() 来测试是否当后台代理启动时,wi-fi 网络或任何网络可用,并且还用于

DeviceNetworkInformation.ResolveHostNameAsync(
                    new DnsEndPoint("microsoft.com", 80),
                    NameResolutionCallback,
                    null);

确定实际使用的网络。

I have an app that uses a background agent to access the web and the local network via wi-fi - not cellular. When the phone is locked, the wi-fi network is not available when the background agent runs - at least on the Samsung Focus Flash phone. I also have an older LG Quantum phone which seems to work ok when the background agent runs - at least when it is plugged in. I'm trying it now without being plugged in to see if that accounts for the difference in behaviour.

(UPDATE: IF the Samsung Flash Focus is plugged in (charging), it also provides wi-fi access when the background agent starts, so that explained the difference in behaviour between the Samsung and the LG Quantum.

So, now the ONLY question remaining is "How can you force the phone to turn on the wi-fi when the background agent starts AND it is NOT plugged in?" )

I use the method NetworkInterface.GetIsNetworkAvailable() to test if the wi-fi network or any network is available when the background agent starts and also use

DeviceNetworkInformation.ResolveHostNameAsync(
                    new DnsEndPoint("microsoft.com", 80),
                    NameResolutionCallback,
                    null);

to determine which network is actually used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟燃烟灭 2025-01-09 11:09:49

在 Windows Phone 7 上,只有满足以下条件之一时,WiFi 才会保留:

  • 交流电源
  • 背光
  • 数据活动

现在,我相信某些应用程序有办法欺骗数据活动(我认为是关于背景音频的),但我不是确定如何做。

请参阅:http://lumiatips.com/keep-wifi-alive -for-windows-phone-homebrew.html

On Windows Phone 7, WiFi only stays if one of the following conditions is true:

  • AC Power
  • Back light on
  • Data activity

Now, I believe some apps have a way to spoof data activity (something about background audio I think), but I am not sure how to.

See: http://lumiatips.com/keep-wifi-alive-for-windows-phone-homebrew.html

拿命拼未来 2025-01-09 11:09:49

我认为你想要的是让后台代理每 30 分钟左右运行一次。如果这是正确的,那么恐怕没有办法做到这一点。当设备处于非活动状态时,Windows Phone 不会调度后台代理以节省电池。这是一个很好的设计。

但是,一旦您触摸电源按钮并进入锁定屏幕,应用程序的后台代理应在 2 - 3 秒左右运行。大多数时候这都能达到目的。

一般来说,后台代理在进行网络呼叫时,会打开网络是Wifi还是蜂窝网络。

I think what you want is to make background agent run every 30 minutes or so. If that is correct then I am afraid there is no way to do that. When the device is inactive windows phone does not schedule background agent to save battery. This is a good design.

However once you touch the power button and get the lock screen the background agent of your app should run in 2 - 3 seconds or so. That serves the purpose most of the time.

Generally background agent while making a network call, turns on the network be is Wifi or cellular.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文