1)在Telephony Framework内部。能够直接使用GSMPhone或GeminiPhone提供的接口。
KK之前的版本号:
IMEI(International Mobile Equipment Identity)是国际移动设备身份码。在单卡project中一个手机相应一个IMEI号,双卡project中一张卡相应一个IMEI号。
以下是获得IMEI号的接口和demo code
API:
GSMPhone.java     中getDeviceId()
GeminiPhone.java  中getDeviceId() 和 getDeviceIdGemini()
 
Demo code:
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.gemini.GeminiPhone;
import com.android.internal.telephony.PhoneFactory;  
Phone phone;
phone = PhoneFactory.getDefaultPhone();
String  imei=(GeminiPhone)phone.getDeviceId();
 
GeminiPhone mGeminiPhone;
String imei_sim1 = mGeminiPhone.getDeviceIdGemini(PhoneConstants.GEMINI_SIM_1);
String imei_sim2 = mGeminiPhone.getDeviceIdGemini(PhoneConstants.GEMINI_SIM_2);
 
KK版本号上:
GSMPhone.java    中getDeviceId()
GeminiPhone.java 当中getDeviceIdGemini()已经没有了,而getDeviceId()获取的是default phone的IMEI;
所以直接使用GSMPhone.java中getDeviceId()方法; 
Demo code:
GeminiPhone mGeminiPhone;
String imei_sim1=mGeminiPhone.getPhonebyId(PhoneConstants.GEMINI_SIM_1).getDeviceId();
String imei_sim2=mGeminiPhone.getPhonebyId(PhoneConstants.GEMINI_SIM_2).getDeviceId();
 
2)如须要在SDK开发(第三方APK)中获取IMEI号。请使用TelephonyManager中的getDeviceId()方法,或TelephonyManagerEx(双卡接口)中的getDeviceId(int simId)方法。

Demo code(获取DefaultPhone的IMEI):
import android.telephony.TelephonyManager;
String imei_sim = TelephonyManager.getDeviceId();
 
Demo code(双卡接口):
import android.telephony.TelephonyManagerEx;
String imei_sim1 = TelephonyManagerEx.getDeviceId(PhoneConstants.GEMINI_SIM_1);
String imei_sim2 = TelephonyManagerEx.getDeviceId(PhoneConstants.GEMINI_SIM_2);

android 中怎样获取IMEI号的更多相关文章

  1. Qt Add ons Modules(听说QtSystem有接口可以获取 imei号)

    http://wiki.qt.io/Qt-Add-ons-Modules 听说QtSystem有接口可以获取 imei号.http://wiki.qt.io/Qt-Add-ons-Modules这儿下 ...

  2. android 获取IMEI号

    android 获取 imei号码 核心代码: Imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceId( ...

  3. android系统中使用TelephonyManager类来获取imei号和其他手机信息

    在AndroidManifest.xml文件中增加<!--允许读取电话状态SIM的权限--><uses-permission android:name="android.p ...

  4. android中ContentProvider获取联系人 总结

    35.内容提供者:ContentResolver 用内容提供者来获取联系人信息 35-1:权限 <!-- 对联系人的读.写权限 --> <uses-permission androi ...

  5. 微信支付的notify.php中如何获取订单号(php版)

    不要直接使用demo中的notify.php,重写notify.php,继承WxPayNotify(可参考微信api),具体如下: require_once "WxPay.Api.php&q ...

  6. android中如何获取xml界面里的非自定义属性

    获取自定义属性大家都很熟悉了,就不多说了(定义declare-styleable,context.obtainStyledAttributes巴拉巴拉...) 下面我们说一下怎么获取非自定义的属性,比 ...

  7. Android中Spanner获取选中内容和选中位置,根据位置选择对象

    作为一名菜鸟,关于spanner获取选中的内容文字代码,网上后很多 但是根据给出的位置来自动选择对象,这个代码一直没找到 后来找人问了问,才知道就一句话的事,特意在这里记录下 array.xml  X ...

  8. Android 中如何获取 H5 保存在 LocalStorage 的数据

    主要分三步: 写个接口,接收 Js 回调 添加到 WebView 主动调用 Js 获取 比如我要获取保存在 LocalStorage 中的 userKey 字段: 1.写个接口,接收 Js 回调 pu ...

  9. Android中怎样获取SD卡路径

    很多时候我们需要将我们的数据或者apk保存到SD卡中,但是使用绝对路径可能会遇到错误,怎样解决这个问题呢?     可以通过以下方法获取SD卡的路径: Environment.getExternalS ...

随机推荐

  1. Hadoop中maptask数量的决定因素

    刚开始接触hadoop平台的时候 部分初学者对于mapreduce中的maptask的数量是怎么确定的 可能有点迷惑,如果看了jobclient里面的maptask初始化的那段源码,那么就比较清楚了, ...

  2. BZOJ5300 [Cqoi2018]九连环 【dp + 高精】

    题目链接 BZOJ5300 题解 这题真的是很丧病,,卡高精卡到哭 我们设\(f[i]\)表示卸掉前\(i\)个环需要的步数 那么 \[f[i] = 2*f[i - 2] + f[i - 1] + 1 ...

  3. vue虚拟dom原理

    Virual DOM是用JS对象记录一个dom节点的副本,当dom发生更改时候,先用虚拟dom进行diff,算出最小差异,然后再修改真实dom. vue的virtual dom的diff算法是基于sn ...

  4. 自定义Windows服务并实施安装

    1.新建项目DemoService,并添加windows服务,命名DemoService 2.添加代码 using System; using System.Collections.Generic; ...

  5. odp.net 读写oracle blob字段

    DEVELOPER: ODP.NET Serving Winning LOBs: http://www.oracle.com/technetwork/issue-archive/2005/05-nov ...

  6. C# WeakReference(弱引用)

    WeakReference(弱引用)我们平常用的都是对象的强引用,如果有强引用存在,GC是不会回收对象的.我们能不能同时保持对对象的引用,而又可以让GC需要的时候回收这个对象呢?.NET中提供了Wea ...

  7. 如何通过友盟分析发布后App崩溃日志

    http://blog.csdn.net/totogo2010/article/details/39892467 要分析崩溃日志,首先需要保留发布时的编译出来的.xcarchive文件.这个文件包含了 ...

  8. glOrthof 与glFrustumf

    http://www.java123.net/v/533543.html glViewport()函数和glOrtho()函数的理解(转) 在OpenGL中有两个比较重要的投影变换函数,glViewp ...

  9. Use NSArray to specify otherButtonTitles?

    http://stackoverflow.com/questions/1602214/use-nsarray-to-specify-otherbuttontitles UIAlertSheet's c ...

  10. 最简单的基于FFmpeg的AVDevice例子(读取摄像头)【转】

    转自:http://blog.csdn.net/leixiaohua1020/article/details/39702113 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[- ...