求助各位大神,怎么获取手机号码?

因项目需要,需要获取本机的手机号码,找的资料试了一下不行,各位有这方面经验的大哥帮个忙。
telephonyManager.getLine1Number(); 这个方法是行不通的,多谢!

我也碰到过这个问题,目前解决了,是因为服务器和80端口的原因,必须是联通3gwap,方法奉上,仅供参考

public String getNativePhoneNumber(Context context) throws Exception {
String result = "";

String urlStr = "http://v.17186.cn/test.jsp";
Proxy proxy = new Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress("10.0.0.172",80));//联通CTWAP代理地址是10.0.0.172

URL url = new URL(urlStr);

HttpURLConnection conn=(HttpURLConnection) url.openConnection(proxy);

if (conn == null){

throw new IOException("URLConnection instance is null");

}

conn.setConnectTimeout(30000);//

conn.setDoOutput(true); // 发送POST请求必须设置允许输出,表示允许对外输出

conn.setUseCaches(false); // 不使用Cache

conn.setRequestMethod("GET");

conn.setRequestProperty("Accept", "*/*");

conn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接

conn.setRequestProperty("Charset", "UTF-8");

conn.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");

     int responseCode = conn.getResponseCode();  
     Log.e("IndexActivity","responseCode is:"+responseCode);  
     if(responseCode == 200){  
         InputStream stream = conn.getInputStream();  

// stream = new GZIPInputStream(stream);
result = inStream2String(stream);

String temvit = result;
//Log.e("error","result" + result);
int x = temvit.indexOf("

");
temvit = temvit.substring(x);
result = temvit.substring(7,24).trim();
Log.e("error","result: " + result);

}
return result;

}
public String inStream2String (InputStream in) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
return out.toString();
}