TelephonyManager常用方法

通过TelephonyManager可以取得手机电信网络的信息,android.provider.Settings.System可以取得手机的相关设置信息。例如下面

TelephonyManager mTelephonyManager = (TelephonyManager) this
.getSystemService(Service.TELEPHONY_SERVICE);

mTelephonyManager.getLine1Number();//取得手机电话号码
mTelephonyManager.getNetworkCountryIso();//取得电信网络国别
mTelephonyManager.getNetworkOperator();//取得电信网络公司代码
mTelephonyManager.getNetworkOperatorName();//取得电信网络公司名称
mTelephonyManager.getPhoneType();//取得行动通信类型
mTelephonyManager.getNetworkType();//网络类型
mTelephonyManager.isNetworkRoaming();//漫游状态
mTelephonyManager.getDeviceId();//取得手机IMEI
mTelephonyManager.getDeviceSoftwareVersion();//取得手机IMEI SV
mTelephonyManager.getSubscriberId();//取得手机IMSI

//蓝牙服务
ContentResolver cr=this.getContentResolver();
String tmps=android.provider.Settings.System.getString(cr, android.provider.Settings.System.BLUETOOTH_ON);
if(tmps.equals("1"))
{
//已经打开的操作
}
else
{
//未打开的操作
}

//飞行模式是否打开
tmps=android.provider.Settings.System.getString(cr, android.provider.Settings.System.AIRPLANE_MODE_ON);
if(tmps.equals("1"))
{
//已经打开的操作
}
else
{
//未打开的操作
}

//数据漫游模式是否打开
tmps=android.provider.Settings.System.getString(cr, android.provider.Settings.System.DATA_ROAMING);
if(tmps.equals("1"))
{
//已经打开的操作
}
else
{
//未打开的操作
}

 TelephonyManager常用方法