如何在Android模拟器中模拟总网络丢失 [英] How to simulate total network loss in Android Emulator

查看:85
本文介绍了如何在Android模拟器中模拟总网络丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个应用程序,该应用程序需要知道何时没有可用的IP网络连接.我正在使用android.net.conn.CONNECTIVITY_CHANGE广播事件以及ConnectivityManager对状态变化做出反应以实现此目的,但是在模拟器中测试我的设置时遇到了问题.

我已经尝试了两种飞行模式,并按F8键禁用了蜂窝网络",但是即使这两个选项都处于启用状态,应用程序仍然可以看到"底层网络.

有人设法找到一种方法来模拟完全缺乏网络访问权限吗?

解决方案

我已经体验到,按F8键后,状态栏中的图标显示没有连接,但是如果您尝试浏览,它会起作用.也许与以下已打开的错误有关:错误3838

I'm trying to write an application that needs to know when there is no IP network connection available. I am using the android.net.conn.CONNECTIVITY_CHANGE broadcast event along with ConnectivityManager to react to the changes in state to achieve this, but I'm having problems testing my set up in the emulator.

I have tried both flight mode and pressing F8 to disable the "Cellular Network" but even with both of these engaged the application still "sees" the underlying network.

Has anybody managed to find a way to simulate a total lack of network access?

解决方案

I have experienced that after pressing F8 an icon in the status bar shows that there's no connectivity, but if you try to browse it works. Maybe it has something to do with this opened bug: bug 3838

这篇关于如何在Android模拟器中模拟总网络丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆