Android这样获取本机网络提供商呢?请看下面代码:
public String getProvidersName()
{
String str = "N/A";
try
{
this.IMSI = this.telephonyManager.getSubscriberId();
System.out.println(this.IMSI);
if (this.IMSI.startsWith("46000"))
str = "中国移动"; break;
if (this.IMSI.startsWith("46002"))
str = "中国移动"; break ;
if (this.IMSI.startsWith("46001"))
str = "中国联通";
else if (this.IMSI.startsWith("46003"))
str = "中国电信";
}
catch (Exception localException)
{
localException.printStackTrace();
}
return str;
} 注意申明:
this.telephonyManager = ((TelephonyManager)paramContext.getSystemService("phone")); 就这么简单。。。。
来源:http://blog.youkuaiyun.com/zz_mm/article/details/8020210
本文提供了一个简单的Android代码示例,演示如何通过TelephonyManager接口获取设备的网络运营商信息,包括中国移动、中国联通和中国电信。通过检查IMSI(国际移动用户识别码)的前缀来判断运营商。
231

被折叠的 条评论
为什么被折叠?



