如何在android中获取GUID?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2221546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get GUID in android?
提问by Jeyavel
we are developing the application using the .Net webservice(soap protocal) for that i need Pass GUID from android class.
我们正在使用 .Net webservice(soap protocal) 开发应用程序,因为我需要从 android 类传递 GUID。
in .Net we have statement like below Guid myGuid1 = new Guid();
在 .Net 中,我们有如下语句 Guid myGuid1 = new Guid();
i need the similar functionality in Android , is there any way to make this kind of functionality in android code?
我需要 Android 中的类似功能,有什么方法可以在 android 代码中实现这种功能吗?
Regards, Jeyavel N
问候, Jeyavel N
回答by Behnam Bagheri
Yes you should use UUID like the following code:
是的,您应该像以下代码一样使用 UUID:
String uniqueID = UUID.randomUUID().toString();
回答by CommonsWare
You can use the java.util.UUID
class.
您可以使用java.util.UUID
该类。
回答by Vinod Pattanshetti
We can use
我们可以用
String uniqueID = UUID.randomUUID().toString();
An Instance ID or a GUID is scoped to the app that creates it, which prevents it from being used to track users across apps.For more information and significance please refer this link here
实例 ID 或 GUID 的范围仅限于创建它的应用程序,从而防止它被用于跨应用程序跟踪用户。有关更多信息和重要性,请参阅此处的链接
回答by Parth Pandya
You will get UUID in Android,
您将在 Android 中获得 UUID,
UUID uuid = UUID.randomUUID();
String uuidInString = uuid.toString();