首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

失去系统当前的APN

2012-07-04 
得到系统当前的APNpublic static final Uri PREFERAPN_URI Uri.parse(content://telephony/carriers/pr

得到系统当前的APN
    public static final Uri PREFERAPN_URI = Uri.parse("content://telephony/carriers/preferapn");


    /*
     * return current apn name of system.
     */
    private String getCurrentApn() {
        int id = 0;
        Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"},
                null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
        if (null != cursor && cursor.getCount() > 0) {
            cursor.moveToFirst();
            id = cursor.getInt(0);
        }
        cursor.close();
        String where = "_id = " + id;
        cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
                "_id", "name", "apn", "type"}, where, null,
                Telephony.Carriers.DEFAULT_SORT_ORDER);
        String currentApn = "";
        if (null != cursor && cursor.getCount() > 0) {
            cursor.moveToFirst();
            currentApn = cursor.getString(cursor.getColumnIndexOrThrow("apn"));
        }
        cursor.close();
        return currentApn;
    }

热点排行