如何写入WAP MMS APN Settings?

需要设定WAP MMS APN,每次手动设置很麻烦,写了个AP直接写入Wap MMS

 

涉及到两个APN的URI

content://telephony/carriers

content://telephony/carriers/preferapn 当前的APN设定

 

各APN设定如下:

ContentValues values_3gnet = new ContentValues(); 
			values_3gnet.put("NAME", "3gnet"); 
			values_3gnet.put("APN", "3gnet"); 
			values_3gnet.put("PROXY", ""); 
			values_3gnet.put("PORT", ""); 
			values_3gnet.put("USER", ""); 
			values_3gnet.put("PASSWORD", "");
			values_3gnet.put("server", "");
			values_3gnet.put("mmsc", "");
			values_3gnet.put("mmsproxy", "");
			values_3gnet.put("mmsport", "");
			values_3gnet.put("mcc", "460");  
			values_3gnet.put("mnc", "01");
			values_3gnet.put("type", "default");
			values_3gnet.put("numeric", "46001");

ContentValues values_3gwap = new ContentValues(); 
			values_3gwap.put("NAME", "3gwap"); 
			values_3gwap.put("APN", "3gwap"); 
			values_3gwap.put("PROXY", "10.0.0.172"); 
			values_3gwap.put("PORT", "80"); 
			values_3gwap.put("USER", ""); 
			values_3gwap.put("PASSWORD", "");
			values_3gwap.put("server", "http://www.wo.com.cn");
			values_3gwap.put("mmsc", "http://mmsc.mynui.com.cn");
			values_3gwap.put("mmsproxy", "10.0.0.172");
			values_3gwap.put("mmsport", "80");
			values_3gwap.put("mcc", "460");  
			values_3gwap.put("mnc", "01");
			values_3gwap.put("type", "default");
			values_3gwap.put("numeric", "46001");

ContentValues values_3gmms = new ContentValues(); 
			values_3gmms.put("NAME", "3gmms"); 
			values_3gmms.put("APN", "uniwap"); 
			values_3gmms.put("PROXY", "10.0.0.172"); 
			values_3gmms.put("PORT", "80"); 
			values_3gmms.put("USER", ""); 
			values_3gmms.put("PASSWORD", "");
			values_3gmms.put("server", "http://www.wo.com.cn");
			values_3gmms.put("mmsc", "http://mmsc.mynui.com.cn");
			values_3gmms.put("mmsproxy", "10.0.0.172");
			values_3gmms.put("mmsport", "80");
			values_3gmms.put("mcc", "460");  
			values_3gmms.put("mnc", "01");
			values_3gmms.put("type", "mms");
			values_3gmms.put("numeric", "46001");

 

将新建的APN插入APN列表中

ContentResolver resolver = this.getContentResolver();
		ContentValues values = getContentValues(apnType);
		
		Cursor c = null;  
        Uri newRow = resolver.insert(APN_URI, values);
 

 更新APN List

values.put("apn_id", id);  
        resolver.update(APN_URI_DEFAULT, values, null, null);

 别忘了加入Permission.

<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />

你可能感兴趣的:(android,WAP)