如何禁用Android模拟器Internet连接? [英] How to disable Internet Connection in Android Emulator?

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

问题描述

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

i am trying to check internet connectivity in android using the following method. I have a WIFI 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!? Help!

推荐答案

要禁用Internet连接

From Eclipse

To Disable Internet Connection

进入到Eclipse

Go to Eclipse

Window->show view->other->android->Devices

现在选择你的运行模拟器,并再次

now select your running emulator and Again

进入,

Window->show view->other->android->Emulator Control

现在在.. 一组数据,以注销从首页

在设备或模拟器进入,

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

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

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