如何禁用在Android模拟器的互联网连接? [英] How do I disable the Internet connection in Android Emulator?

查看:177
本文介绍了如何禁用在Android模拟器的互联网连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面的方法来检查Android的互联网连接。我有一个Wi-Fi连接。

I am trying to check Internet connectivity on Android using the following method. I have a Wi-Fi connection.

private boolean checkInternetConnection() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    // Test for connection
    if (cm.getActiveNetworkInfo() != null
            && cm.getActiveNetworkInfo().isAvailable()
            && cm.getActiveNetworkInfo().isConnected()) {
        return true;
    }
    else {
        // No conection
        return false;
    }
}

我断开互联网我的电脑,然后尝试运行上面的方法。尽管如此,它总是返回true!?为什么呢?

I disconnect my PC from the Internet and then try to run the above method. Still it always returns true!? Why?

推荐答案

要禁用Internet连接,请转至Eclipse和做

From Eclipse

To disable the Internet connection, go to Eclipse and do

menu Window -> Show view -> Other -> Android -> Devices

现在选择你的运行模拟器,并再次请访问:

Now select your running emulator and again go to:

menu Window -> Show View -> Other -> Android -> Emulator Control

现在在... 设置数据,以注销从首页

在设备或在模拟器,请访问:

On the device or in the emulator, go to:

Setting -> Wireless & networks -> Airplane Mode -> OK

这篇关于如何禁用在Android模拟器的互联网连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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