Imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.getDeviceId();
1.加入权限
在manifest.xml文件中要添加 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
2.代码
代码如下:
package net.sunniwell.app;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
public class TelManager extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
tm.getCallState();//int
tm.getCellLocation();//CellLocation
tm.getDeviceId();//String
tm.getDeviceSoftwareVersion();//String
tm.getLine1Number();//String
tm.getNeighboringCellInfo();//List<NeighboringCellInfo>
tm.getNetworkCountryIso();//String
tm.getNetworkOperator();//String
tm.getNetworkOperatorName();//String
tm.getNetworkType();//int
tm.getPhoneType();//int
tm.getSimCountryIso();//String
tm.getSimOperator();//String
tm.getSimOperatorName();//String
tm.getSimSerialNumber();//String
tm.getSimState();//int
tm.getSubscriberId();//String
tm.getVoiceMailAlphaTag();//String
tm.getVoiceMailNumber();//String
tm.hasIccCard();//boolean
tm.isNetworkRoaming();//
}
}
您可能感兴趣的文章:Android编程实现获取图片资源的四种方法Android中实现根据资源名获取资源IDandroid图像绘制(六)获取本地图片或拍照图片等图片资源Android获取本机电话号码的简单方法解析android中系统日期时间的获取Android获取SD卡中选中图片的路径(URL)示例android获取当前运行Activity名字的方法Android获取ROOT权限的实例代码Android从服务器获取图片的实例方法android 获取视频,图片缩略图的具体实现android 获取上一个activity返回值的方法Android使用getIdentifier()获取资源Id的方法