如何获取设备的IMEI / ESN编程的机器人? [英] How to get the device's IMEI/ESN programmatically in android?

查看:413
本文介绍了如何获取设备的IMEI / ESN编程的机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要确定每个设备的唯一我想用IMEI(或ESN号CDMA设备)。如何以编程方式访问这个?

To identify each devices uniquely I would like to use the IMEI (or ESN number for CDMA devices). How to access this programmatically?

推荐答案

您要拨打<一个href="http://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId()"><$c$c>android.telephony.TelephonyManager.getDeviceId().

这将返回任何字符串唯一标识设备(IMEI在GSM,MEID为CDMA)。

This will return whatever string uniquely identifies the device (IMEI on GSM, MEID for CDMA).

您将需要在以下权限的的Andr​​oidManifest.xml

You'll need the following permission in your AndroidManifest.xml:

&LT;使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE/&GT;

为了做到这一点。

这就是说,要小心这样做。不仅用户不知道为什么你的应用程序访问他们的电话协议栈,它可能很难,如果用户得到一个新的设备上迁移数据。

That being said, be careful about doing this. Not only will users wonder why your application is accessing their telephony stack, it might be difficult to migrate data over if the user gets a new device.

更新:正如下面的评论,这不是一个安全的方式来验证用户身份,并引发隐私担忧。不建议。相反,看看 Google+的登录API 的,如果你想实现一个无摩擦的登录系统。

Update: As mentioned in the comments below, this is not a secure way to authenticate users, and raises privacy concerns. It is not recommended. Instead, look at the Google+ Login API if you want to implement a frictionless login system.

href="http://developer.android.com/training/cloudsync/backupapi.html"> Android的备份API 也可以,如果你只是想要一个轻量级的方式坚持一捆的

The Android Backup API is also available if you just want a lightweight way to persist a bundle of strings for when a user resets their phone (or buys a new device).

这篇关于如何获取设备的IMEI / ESN编程的机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆