首页 > 系统 > Android > 正文

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

2019-10-24 20:41:13
字体:
来源:转载
供稿:网友
这篇文章主要介绍了android获取当前接入点信息判断是ctwap还是ctnet的方法,大家参考使用吧
 
复制代码代码如下:

/**
     * 获取当前的接入点是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;
    }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表