如何检查在Android上网(包括圈养!)? [英] How to check internet access (INCLUDING tethering!) on Android?

查看:185
本文介绍了如何检查在Android上网(包括圈养!)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找了一块code的,将检查Android设备,包括圈养,不仅无线信道的网络连接。

I am looking for a piece of code that would check network connectivity, of an Android device, including tethering, not only the wireless channels.

我在网上花了几个小时寻找这样的事情,但没有任何结果!所有我发现功能仅管理无线网卡的测试。有没有什么束缚。那么,这至少可能吗?你有没有一些相应的?

I have spent hours online looking for such a thing, but without any result! All the functions I found out manage only wireless net tests. Nothing with tethering. So is it at least possible? Do you have some corresponding?

推荐答案

此检查是否启用了圈养。从类切我改变让adbWireless工作过绳连接:

this checks if Tethering is enabled. Cut from a class I changed to get adbWireless working over a tethered connection:

    // check if tethering is on
    try {
        Method[] wmMethods = mWifiManager.getClass().getDeclaredMethods();
        for(Method method: wmMethods)
            if(method.getName().equals("isWifiApEnabled")) {
                boolean isOn = (Boolean) method.invoke(mWifiManager);
                return isOn;
            }
        return false;
    } catch (Exception e) {return false;}

和则还需要android.permission.ACCESS_WIFI_STATE

And you also need android.permission.ACCESS_WIFI_STATE

这篇关于如何检查在Android上网(包括圈养!)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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