Device: rk3188
Platform Version: Android 4.4
分为以下两个步骤
- Apn读取
- Apn写入
Apn读取
apns-conf.xml—>telephony.db
-
apns-conf.xml放在system/etc/
-
telephony.db放在data/data/com.android.providers.telephony/databases/下如果找不到可以用find在/data/下查找
-
第一次开机时将apns-conf.xml中apn信息加载进telephony.db,后面再次开机不会再加载,除非apn-conf.xml被更新并升级或者telephony.db被删除了。
-
如果想增加可以将新的apn加进apn-conf.xml,并删除telephony.db,然后reboot就可以了。
-
打开4G的时候读取sim卡的mcc和mnc去telephony.db,成功并在APN页显示出来
private static final String PREFERRED_APN_URI = "content://telephony/carriers/preferapn"; private static final Uri PREFERAPN_URI = Uri.parse(PREFERRED_APN_URI); Cursor cursor = mContext.getContentResolver() .query(PREFERAPN_URI, null, null, null, null);
Apn写入
Uri uri = mContext.getContentResolver().insert(Telephony.Carriers.CONTENT_URI, values);
long insertId = ContentUris.parseId(uri);
ContentValues preferValues = new ContentValues();
preferValues.put(APN_ID, insertId);
mContext.getContentResolver().update(PREFERAPN_URI, preferValues, null, null);
转载请注明出处:http://www.wolfnx.com/2017/11/12/Apn
作者 : wolfnx
邮箱 : wolfnx@outlook.com
邮箱2 : lostnx@gmail.com