如何在Android中获取GUID?


67

我们正在开发使用.Net Web服务(肥皂协议)的应用程序,因为我需要从android类传递GUID。

在.Net中,我们有如下语句:Guid myGuid1 = new Guid();

我需要Android中的类似功能,是否有任何方法可以在Android代码中实现这种功能?

此致Jeyavel N

Answers:



84

是的,您应该像以下代码一样使用UUID:

String  uniqueID = UUID.randomUUID().toString(); 

请注意,这为您提供了类型4 UUID,它只是一个随机值。的UUID类不能产生1型的UUID(基于时间)。
jcayzac

10

我们可以用

String uniqueID = UUID.randomUUID().toString();

实例ID或GUID的范围仅限于创建它的应用程序,这将阻止它用于跨应用程序跟踪用户。有关更多信息和重要性,请在此处引用此链接


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.