当前位置: 移动技术网 > IT编程>移动开发>Android > android获取当前接入点信息判断是ctwap还是ctnet实例代码

android获取当前接入点信息判断是ctwap还是ctnet实例代码

2019年07月24日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

/**
     * 获取当前的接入点是ctwap还是ctnet
    * @author <a href="mailto:yejiurui@126.com">yejiurui</a>
     * @version 1.0 2013-5-17 下午5:46:05  2013
     */
    private  string ctwap="ctwap";
    private  string ctnet="ctnet";
    private  uri preferred_apn_uri = uri
        .parse("content://telephony/carriers/preferapn");

    public  string getapntype(context context) {
        string apntype = "nomatch";
        cursor c = context.getcontentresolver().query(preferred_apn_uri, null,
                null, null, null);
        c.movetofirst();
        string user = c.getstring(c.getcolumnindex("apn"));
        if (user.startswith(ctnet)) {
            apntype = ctnet;
        } else if (user.startswith(ctwap)) {
            apntype = ctwap;
        }
        return apntype;
    }

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网