我想测试我的应用程序的低网络连接的情况。除了站在电梯里,还有什么最好的方法呢?我试过用铝箔纸包我的手机,但没有用。

我需要在真正的设备上测试它,而不是在模拟器上。


当前回答

在Android Studio中打开终端,进入../../Android/sdk/tools。'模拟器'可执行文件应该在这里可用。 运行。/emulator -netdelay "delay_in_millis" -avd "emulator_device_name" 例如:./emulator -netdelay 60000 -avd Nexus_5_API_21 现在构建应用程序并将其安装在模拟器中。 在应用程序中运行您的场景。

确保你有你的代码变化在应用程序设置超时你的请求和处理。

其他回答

您是想测试没有网络连接,还是只是网络连接很慢?如果是前者,可以进入设置>无线和网络>飞行模式,打开飞行模式。这将允许您在实际设备上测试网络不可用性。

有一种在真实设备上测试低速的简单方法似乎被忽视了。它确实需要一台Mac电脑和以太网(或其他有线)网络连接。

在Mac上打开Wifi共享,把你的电脑变成Wifi热点,把你的设备连接到这个。使用Netlimiter/Charles Proxy或Network Link Conditioner(您可能已经安装了)来控制速度。

欲了解更多详细信息,并了解您应该在签出时测试什么样的速度:http://opensignal.com/blog/2016/02/05/go-slow-how-why-to-test-apps-on-poor-connections/

Facebook建立了一个叫做增强交通控制的东西。GitHub页面上的简要总结:

Augmented Traffic Control (ATC) is a tool to simulate network conditions. It allows controlling the connection that a device has to the internet. Developers can use ATC to test their application across varying network conditions, easily emulating high speed, mobile, and even severely impaired networks. Aspects of the connection that can be controlled include: bandwidth latency packet loss corrupted packets packets ordering In order to be able to shape the network traffic, ATC must be running on a device that routes the traffic and sees the real IP address of the device, like your network gateway for instance. This also allows any devices that route through ATC to be able to shape their traffic. Traffic can be shaped/unshaped using a web interface allowing any devices with a web browser to use ATC without the need for a client application.

你可以在GitHub上找到它:https://github.com/facebook/augmented-traffic-control

他们还为此写了一篇博客:https://code.facebook.com/posts/1561127100804165/augmented-traffic-control-a-tool-to-simulate-network-conditions/

非常老的帖子,但我将补充我的意见。我对这个硬件产品(https://apposite-tech.com/products/linktropy-mini/)非常满意,它使我们能够模拟许多现实世界的条件。在很长一段时间里,我们都面临着解决各种问题的挑战,这些问题将在模拟器或飞行模式下工作。

我们设置了几个不同的配置文件,从零连接到边缘连接的各个阶段,具有不同程度的延迟、数据包丢失和误码。这样做的好处是我们可以在运行中更改这些,而不必在模拟器中重新启动应用程序。对于我们的商店来说,这个价格是完全值得的,而且使用起来非常简单。

我发现netlimiter4是将数据节流到模拟器的最佳解决方案。 它通过体面的gui提供粒度控制,并为每个进程的数据吞吐量提供图形化反馈。目前处于免费测试版。 截图

http://www.netlimiter.com/products/nl4

在游戏商店中有一些应用程序可以节流到实际设备上,但它们需要root(我不能提供任何关于它们工作得如何的建议,如果在所有- YMMV)。

在游戏商店搜索bradybound,我不能发布超过一个链接。