android gets the current access point information to determine whether it is ctwap or ctnet instance code

  • 2020-05-19 05:51:24
  • OfStack


/**
     *  Gets the current access point is ctwap or ctnet
    * @author <a href="mailto:yejiurui@126.com">yejiurui</a> 
     * @version 1.0 2013-5-17  In the afternoon 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;
    }

Related articles: