Android這樣獲取本機網絡提供商呢?請看下面代碼:
[java]
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;
}
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;
}註意申明:
[java]
this.telephonyManager = ((TelephonyManager)paramContext.getSystemService("phone"));
this.telephonyManager = ((TelephonyManager)paramContext.getSystemService("phone"));
就這麼簡單。。。。