其中并产生android.Build.SERIAL时AOSP? [英] Where and when is generated android.Build.SERIAL in AOSP?

查看:577
本文介绍了其中并产生android.Build.SERIAL时AOSP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道, android.Build.SERIAL 在第一次设备启动时产生的,但我不能找到确切位置和时间。我建立 AOSP果冻豆,Android平板电脑,nosdcard。

第二个问题:就是这个序列号的真的唯一的所有安卓设备

解决方案

根据这线程,它清楚地说,这是唯一的,但由于API 9添加,可能是在所有设备上没有present。

如果你正在编写你的应用程序特定设备的型号,你可以direclty检查它是否有一个IMEI。否则,像你说的,我建议你写一个自定义ID生成模块。
你一定会认为你的ID是唯一的,可用于所有设备。

IMEI重新presents的设备的序列号。这是确保它是独一无二的。两个不同的设备不能具有相同的序列号

要获取设备的序列号,你只需要调用:

 字符串序列= Build.SERIAL;
 

它存在的另一种方法。你可以通过调用 安全获得ID。 ANDROID_ID

  

一个64位数字(作为一个十六进制字符串)是随机的产生   设备的首次启动,并应保持不变的寿命   设备。 (如果在执行出厂重置价值可能会改变   装置。)

 私有最终字符串ANDROID_ID = Secure.getString(的getContext()。getContentResolver()
                                                        Secure.ANDROID_ID);
 

小心,因为它说,该值可以如果执行了出厂重置的变化。

I know, that android.Build.SERIAL is generated at first device boot, but I can't locate where and when exactly. I'm building AOSP Jelly Bean, Android tablet, nosdcard.

2nd question: is this serial number really unique for all Android devices?

解决方案

According to this thread, it clearly says that it's unique, but added since API 9 and may be not present on all devices.

If you're writing your app for a specific device's model, you could direclty check if it has an IMEI. Otherwise, as you said, I recommend you to write a custom ID generator module.
You will be sure that your ID will be unique and available for all devices.

IMEI represents the serial number of the device. It's sure it's unique. Two different devices can't have the same serial number.

To get the serial number of the device you just have to call :

String serial =  Build.SERIAL;

It exists another approach. You can get the id by calling Secure.ANDROID_ID.

A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

private final String ANDROID_ID = Secure.getString(getContext().getContentResolver(),
                                                        Secure.ANDROID_ID);

Take care because it says that the value MAY change if a factory reset is performed.

这篇关于其中并产生android.Build.SERIAL时AOSP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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