`
googlelee
  • 浏览: 114559 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

获取APN的函数

 
阅读更多
/*copy by LEE*/
public static String getAPN(Context context) { 
        // 通过context得到ConnectivityManager连接管理 
        String apn = null;
ConnectivityManager manager = (ConnectivityManager) context 
                .getSystemService(Context.CONNECTIVITY_SERVICE); 
        // 通过ConnectivityManager得到NetworkInfo网络信息 
        NetworkInfo info = manager.getActiveNetworkInfo(); 
        // 获取NetworkInfo中的apn信息 
        if (info != null) { 
            apn = info.getExtraInfo(); 
            if (apn == null) { 
                apn = "取不到移动网络信息"; 
            } 
        } else { 
            apn = "取不到网络信息"; 
        } 
        return apn; 
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics