·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> Android开发 >> android获取当前接入点信息判断是ctwap还是ctnet实例代码

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

作者:佚名      Android开发编辑:admin      更新时间:2022-07-23
复制代码 代码如下:
/**
     * 获取当前的接入点是ctwap还是ctnet
    * @author <a href="mailto:[email protected]">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;
    }