---
title: "TelephonyManager常用方法"
author: "bywyu"
date: "2010-09-19T09:51:20Z"
tags: []
categories: ["移动开发"]
slug: "telephonymanager"
draft: false
lastmod: "2010-09-19T09:58:25Z"
id: 766959
url: "https://bywyu.iteye.com/blog/766959"
---

通过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
{
//未打开的操作
}
```

 ![](http://hiphotos.baidu.com/worldofhua/pic/item/5fcf2dcf2077237ef9dc6182.jpg)