如何在奶源Android的无线互联网连接? [英] how to mange wifi internet connectivity in android?

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

问题描述

我用下面的code,检查3G,在Android手机应用边缘连接

 公共布尔isConnected()
    {
        尝试
        {
            最后ConnectivityManager conn_manager =(ConnectivityManager)
            this.getSystemService(Context.CONNECTIVITY_SERVICE);            最终的NetworkInfo network_info = conn_manager.getActiveNetworkInfo();
            如果(network_info = NULL&放大器;!&安培; network_info.isConnected())
            {
                返回true;
            }
            其他
            {
                返回false;
            }
        }
        赶上(例外五)
        {
            返回false;        }
    }

如果我把它连接到无线网络,然后该检查工作不正常
实际上,当无线连接到网络和互联网覆盖率不存在上述检查说好逸岸的错任何一个指导我如何处理丢包情况下,像

正在添加互联网然后disconnnecting这个过程一直持续在android系统?
还是我做错了什么?

任何帮助将是AP preciated。


解决方案

  

如果我把它连接到无线网络,然后这个检查不能正常工作


是的,确实如此,由您自己也承认。


  

其实,当无线连接到网络和互联网覆盖率不存在上述检查说好


这是什么是应该做的。 WiFi网络被激活,这意味着Android是与接入点通信。这就是连接的意思。

您可以告诉你,如果可以在一定主机通信的唯一方法是尽量传达给某些主机。需要注意的是 requestRouteToHost()据报道,有问题,所以你需要到别的尝试一些(例如,建立HTTP连接到已知的良好URL)。

i use following code to check 3g,edge connectivity in android phone application

public boolean isConnected()
    {
        try
        {
            final ConnectivityManager conn_manager = (ConnectivityManager) 
            this.getSystemService(Context.CONNECTIVITY_SERVICE);

            final NetworkInfo network_info = conn_manager.getActiveNetworkInfo();
            if ( network_info != null && network_info.isConnected() ) 
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception e) 
        {
            return false;

        }
    }

if i connect it to wifi then this check does not work correctly actually when wifi is connected to network and internet coverage is not there above check say ok infact its wrong any one guide me how to handle packet lost case like

internet comming then disconnnecting and this process keeps continue in android ? or am i doing something wrong?

any help would be appreciated.

解决方案

if i connect it to wifi then this check does not work correctly

Yes, it does, by your own admission.

actually when wifi is connected to network and internet coverage is not there above check say ok

That is what it is supposed to do. Your WiFi network is active, meaning Android is in communication with your access point. That is what "connected" means.

The only way you can tell if you can communicate to some host is to try to communicate to some host. Note that requestRouteToHost() reportedly has issues, so you would need to try something else (e.g., make an HTTP connection to a known good URL).

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

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