根本原因apns-conf.xml里面没有 符合 物理网卡 的配置
可以先加一个APN试一下,看看默认的MCC和MNC是什么
然后在”命令行“查询一下
adb shell sqlite3 /data/user_de/0/com.android.providers.telephony/databases/telephony.db "'select * from carriers where mcc=\"460\" and mnc=\"13\";'"
如果是空就证明没有要添加一条
刷机的要在apns-conf.xml里加
升级的要在它就不会再从apns-conf.xml里去读,要代码里动态加,要看你的卡是哪张卡,仿照下面的写吧,改一下是哪张卡
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.provider.Telephony;+ setSelectedApnKey();//-------------------加在你想加的位置+ public static final String PREFERRED_APN_URI = "content://telephony/carriers/";+private void setSelectedApnKey() {+ final ContentResolver resolver =mContext.getContentResolver();
+
+ final ContentValues values = new ContentValues();
+ values.put(Telephony.Carriers.NAME, "aaa");
+ values.put(Telephony.Carriers.MMSPROXY,"");
+ values.put(Telephony.Carriers.MMSPORT,"");
+ values.put(Telephony.Carriers.MMSC,"");
+
+ values.put(Telephony.Carriers.TYPE,"mms");
+
+ values.put(Telephony.Carriers.MCC, "460");
+ values.put(Telephony.Carriers.MNC, "13");
+
+ values.put(Telephony.Carriers.NUMERIC, "460" + "13");
+
+ /*if (mCurMnc != null && mCurMcc != null) {
+ if (mCurMnc.equals(mnc) && mCurMcc.equals(mcc)) {
+ values.put(Telephony.Carriers.CURRENT, 1);
+ }
+ }*/
+ //values.put("apn_id", key);
+ resolver.insert(getUriForCurrSubId(Uri.parse(PREFERRED_APN_URI)), values);
+ }
+ private Uri getUriForCurrSubId(Uri uri)
+ {
+ SubscriptionInfo mSubscriptionInfo =getSubscriptionInfo(1);
+ final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
+ : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ if (SubscriptionManager.isValidSubscriptionId(subId)) {
+ return Uri.withAppendedPath(uri, "subId/" + String.valueOf(subId));
+ } else {
+ return uri;
+ }
+ }
+
+ private SubscriptionInfo getSubscriptionInfo(int subId) {
+ return SubscriptionManager.from(getActivity()).getActiveSubscriptionInfo(subId);
+ }