This question already has an answer here:
这个问题已经有了答案:
- Is there a unique Android device ID? 38 answers
- 有唯一的Android设备ID吗?38个答案
How to get the unique device ID in Android which cannot be changed when performing a phone reset or OS update?
如何在Android中获得在执行手机重置或操作系统更新时不能更改的唯一设备ID ?
4 个解决方案
#1
132
You check this blog in the link below
你可以在下面的链接中查看这个博客
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
ANDROID_ID
ANDROID_ID
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
The above is from the link @ Is there a unique Android device ID?
以上是来自链接@是否有唯一的Android设备ID?
More specifically, Settings.Secure.ANDROID_ID. This is a 64-bit quantity that is generated and stored when the device first boots. It is reset when the device is wiped.
更具体地说,Settings.Secure.ANDROID_ID。这是一个64位的量,在设备第一次启动时生成并存储。当设备被擦除时重置。
ANDROID_ID seems a good choice for a unique device identifier. There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“Froyo”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.
android id似乎是唯一设备标识符的好选择。缺点是:首先,在2.2(“Froyo”)之前,Android的发布不是100%可靠的。此外,在一家主要制造商的流行手机中,至少有一个广泛观察到的bug,每个实例都具有相同的ANDROID_ID。
The below solution is not a good one coz the value survives device wipes (“Factory resets”) and thus you could end up making a nasty mistake when one of your customers wipes their device and passes it on to another person.
下面的解决方案不是一个好的解决方案,因为该值在设备擦除(“工厂重置”)之后仍然存在,因此当您的一个客户擦去他们的设备并将其传递给另一个人时,您最终可能会犯严重的错误。
You get the imei number of the device using the below
你可以使用下面的方法得到设备的imei号码。
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();
http://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId%28%29
http://developer.android.com/reference/android/telephony/TelephonyManager.html getDeviceId % 29 28%
Add this is manifest
添加这是清单
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
#2
19
I use following code to get Android id.
我使用以下代码获得Android id。
String android_id = Secure.getString(this.getContentResolver(),
Secure.ANDROID_ID);
Log.d("Android","Android ID : "+android_id);
#3
1
Please read this official blog entry on Google developer blog: http://android-developers.blogspot.be/2011/03/identifying-app-installations.html
请阅读谷歌开发者博客的官方博客:http://android- developers.blogspot.be/2011/03/identifyapp -installations.html
Conclusion For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward.
结论对于绝大多数应用来说,需求是确定一个特定的安装,而不是物理设备。幸运的是,这样做很简单。
There are many good reasons for avoiding the attempt to identify a particular device. For those who want to try, the best approach is probably the use of ANDROID_ID on anything reasonably modern, with some fallback heuristics for legacy devices
避免试图识别特定设备的原因有很多。对于那些想要尝试的人来说,最好的方法可能是使用ANDROID_ID在任何合理的现代版本上,并使用一些用于遗留设备的后继启发式方法。
.
。
#4
-30
We can easily get device id by using String id = android.os.Build.ID;
我们可以使用String id = android.os.Build.ID轻松获取设备id;
#1
132
You check this blog in the link below
你可以在下面的链接中查看这个博客
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
ANDROID_ID
ANDROID_ID
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
The above is from the link @ Is there a unique Android device ID?
以上是来自链接@是否有唯一的Android设备ID?
More specifically, Settings.Secure.ANDROID_ID. This is a 64-bit quantity that is generated and stored when the device first boots. It is reset when the device is wiped.
更具体地说,Settings.Secure.ANDROID_ID。这是一个64位的量,在设备第一次启动时生成并存储。当设备被擦除时重置。
ANDROID_ID seems a good choice for a unique device identifier. There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“Froyo”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.
android id似乎是唯一设备标识符的好选择。缺点是:首先,在2.2(“Froyo”)之前,Android的发布不是100%可靠的。此外,在一家主要制造商的流行手机中,至少有一个广泛观察到的bug,每个实例都具有相同的ANDROID_ID。
The below solution is not a good one coz the value survives device wipes (“Factory resets”) and thus you could end up making a nasty mistake when one of your customers wipes their device and passes it on to another person.
下面的解决方案不是一个好的解决方案,因为该值在设备擦除(“工厂重置”)之后仍然存在,因此当您的一个客户擦去他们的设备并将其传递给另一个人时,您最终可能会犯严重的错误。
You get the imei number of the device using the below
你可以使用下面的方法得到设备的imei号码。
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();
http://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId%28%29
http://developer.android.com/reference/android/telephony/TelephonyManager.html getDeviceId % 29 28%
Add this is manifest
添加这是清单
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
#2
19
I use following code to get Android id.
我使用以下代码获得Android id。
String android_id = Secure.getString(this.getContentResolver(),
Secure.ANDROID_ID);
Log.d("Android","Android ID : "+android_id);
#3
1
Please read this official blog entry on Google developer blog: http://android-developers.blogspot.be/2011/03/identifying-app-installations.html
请阅读谷歌开发者博客的官方博客:http://android- developers.blogspot.be/2011/03/identifyapp -installations.html
Conclusion For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward.
结论对于绝大多数应用来说,需求是确定一个特定的安装,而不是物理设备。幸运的是,这样做很简单。
There are many good reasons for avoiding the attempt to identify a particular device. For those who want to try, the best approach is probably the use of ANDROID_ID on anything reasonably modern, with some fallback heuristics for legacy devices
避免试图识别特定设备的原因有很多。对于那些想要尝试的人来说,最好的方法可能是使用ANDROID_ID在任何合理的现代版本上,并使用一些用于遗留设备的后继启发式方法。
.
。
#4
-30
We can easily get device id by using String id = android.os.Build.ID;
我们可以使用String id = android.os.Build.ID轻松获取设备id;