最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android基于APN獲取手機(jī)號(hào)的方法

 更新時(shí)間:2015年07月21日 10:52:46   作者:華宰  
這篇文章主要介紹了Android基于APN獲取手機(jī)號(hào)的方法,實(shí)例分析了Android使用APN獲取手機(jī)號(hào)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了Android基于APN獲取手機(jī)號(hào)的方法。分享給大家供大家參考。具體如下:

之前很多人說無法完全獲取手機(jī)號(hào),是因?yàn)楝F(xiàn)在有的卡不能獲取,有的卡能獲取,現(xiàn)在我們可以換一種思路來考慮問題,就是用APN的方式。請(qǐng)看代碼:

APNNET.java如下:

/** 
* 電信APN列表 
* @author wudongdong 
* 
*/ 
public class APNNET { 
public static String CTWAP="ctwap"; 
public static String CTNET="ctnet"; 
} 
/** 
* 電信APN列表 
* @author wudongdong 
* 
*/ 
public class APNNET { 
public static String CTWAP="ctwap"; 
public static String CTNET="ctnet"; 
} 
//獲得APN的類型  
/** 
* 獲得APN類型 
* @author wudongdong 
* 
*/ 
public class ApnUtil { 
private static Uri PREFERRED_APN_URI = Uri 
.parse("content://telephony/carriers/preferapn"); 
/** 
* get apntype 
* @param context 
* @return 
*/ 
public static 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("user")); 
if(user.startsWith(APNNET.CTNET)){ 
apntype=APNNET.CTNET; 
}else if(user.startsWith(APNNET.CTWAP)){ 
apntype=APNNET.CTWAP; 
} 
return apntype; 
} 
} 
/** 
* 獲得APN類型 
* @author wudongdong 
* 
*/ 
public class ApnUtil { 
private static Uri PREFERRED_APN_URI = Uri 
.parse("content://telephony/carriers/preferapn"); 
/** 
* get apntype 
* @param context 
* @return 
*/ 
public static 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("user")); 
if(user.startsWith(APNNET.CTNET)){ 
apntype=APNNET.CTNET; 
}else if(user.startsWith(APNNET.CTWAP)){ 
apntype=APNNET.CTWAP; 
} 
return apntype; 
} 
}

Java代碼如下:

/**
 獲得手機(jī)號(hào)碼的話可以傳IMSI碼到指定接口,接口地址不方便說。但可以透露一點(diǎn),必須走CTWAP,這也是判斷APN類型的原因,發(fā)現(xiàn)很多應(yīng)用如果APN是走代理的話就不能聯(lián)網(wǎng),那么再介紹一下用APN設(shè)置網(wǎng)絡(luò)的代理信息。
 */
  Cursor c = context.getContentResolver().query(PREFERRED_APN_URI,null, null, null, null); 
  c.moveToFirst(); 
  String proxy=c.getString(c.getColumnIndex("proxy")); 
  if (!"".equals(proxy) && proxy!=null) { 
  Properties prop = System.getProperties(); 
  System.getProperties().put("proxySet", "true"); 
  prop.setProperty("http.proxyHost", c.getString(c.getColumnIndex("proxy"))); 
  prop.setProperty("http.proxyPort", c.getString(c.getColumnIndex("port"))); 
  String authentication = c.getString(c.getColumnIndex("user")) 
  + ":" + c.getString(c.getColumnIndex("password")); 
  String encodedLogin = Base64.encode(authentication); 
  uc.setRequestProperty("Proxy-Authorization", " BASIC " 
  + encodedLogin); 
  } 
  c.close();

希望本文所述對(duì)大家的Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

什邡市| 湘乡市| 沅江市| 安多县| 新宾| 连云港市| 广州市| 连云港市| 德令哈市| 祁门县| 江源县| 化州市| 崇义县| 星座| 沁水县| 古田县| 台江县| 和龙市| 库尔勒市| 阳谷县| 金门县| 冀州市| 南丰县| 阿图什市| 新邵县| 浠水县| 绥芬河市| 洛宁县| 枝江市| 葵青区| 黄浦区| 萨嘎县| 高陵县| 云浮市| 惠水县| 河北区| 邓州市| 泽州县| 大余县| 沾化县| 金川县|