java as uuid,Android和Java Uuid

I want to generate a uuid for my app i tried many things like wifi mac address , getting android id, serial number , creating pseudo uuid from device

android.os.Build properties .

i also came to know that java itself got Uuid creator class

java.util.UUID

by going through several articles and blogs i am little confused about this . i want to know that if two android device are creating uuid using this java class(java.util.UUID) will that be unique or is there any chance for duplication?

Also in some devices i was not able to find serial number using android.os.Build.SERIAL . is there alternative way to get serial number of device

解决方案

Assuming you're using the java.util.UUID's randomUUID() function there's a theoretical chance of duplication, but it's incredibly remote. The ids generated are RFC4122 version-4 ids, which have 122 bits randomly set. That means there are 5.32 x 10^^36 possible values. For some perspective on that, if you had a billion devices, each generating a billion IDs per second, it would take roughly 168 billion years for them to finish (~10X the age of the universe).

So, yes, duplication is possible, but (assuming Java is using a high quality random number generator), the odds of it actually happening are so remote as to be meaningless.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值