UUID
Upcoming SlideShare
Loading in...5
×
 

UUID

on

  • 471 views

How to use UUID in Java and Android.

How to use UUID in Java and Android.

Statistics

Views

Total Views
471
Views on SlideShare
445
Embed Views
26

Actions

Likes
2
Downloads
1
Comments
0

1 Embed 26

https://twitter.com 26

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    UUID UUID Presentation Transcript

    • UUID Tomoki Yamashita 2014.4.9 potatotips #6
    • Self-Introduction • @tomorrowkey / Tomoki Yamashita • Android Developer at COOKPAD • http://blog.tomorrowkey.jp / 明日の
    • Agenda • What is UUID? • How to use it in Java • Versions of UUID • Which version can we use in Java • To use version 1 in Java • To use version 1 in Android
    • What is UUID
    • What is UUID? • Universally Unique Identifier • RFC 4122 • Generate Unique ID without servers.
    • How to use in Java
    • How to use it in Java import java.util.UUID;
 
 public class Main {
 public static void main(String... args) {
 UUID uuid = UUID.randomUUID();
 System.out.println(“uuid=” + uuid.toString());
 }
 } # 53da3b97-075f-4bcd-af62-148b1a7d6712
    • Versions of UUID
    • Versions of UUID • There are 5 versions of UUID.
    • Version 1 • Original version • Use time(nano-seconds) and Mac Address • It won't duplicate because depends on mac address.
    • Version 2 • Version for DCE(Distributed Computing Environment) Security
    • Version 3 • Name and MD5 Hash • If use the same name, it duplicate.
    • Version 4 • Random value • It may not duplicate.
    • Version 5 • Name and SHA1 Hash • If use the same name, it duplicate.
    • Which version can we use in Java?
    • Which version can we use in Java? • Version 3
 UUID.nameUUIDFromBytes(byte[] name) • Version 4
 UUID.randomUUID();
    • To use version1 in Java
    • To use version1 in Java stephenc/eaio-uuid 
 https://github.com/stephenc/eaio-uuid
    • To use version1 in Java build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString());
    • To use version1 in Android
    • To use version1 in Android build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString());
    • To use version1 in Android build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString()); NoClassDefFoundError: com.eaio.uuid.UUID
    • Why...? The library use a api which is not supported in Android. omg.CORBA.portable.IDLEntity
    • To use version1 in Android • clone eaio-uuid • remove CORBA api from source code. • add a permission INTERNET
    • End Understand principle about UUID and then use it. Thank you for listening
    • Referred links RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace 
 http://tools.ietf.org/html/rfc4122 Universally unique identifier - Wikipedia, the free encyclopedia 
 http://en.wikipedia.org/wiki/UUID#Variants_and_versions UUIDはなぜ、分散環境で好き勝手に生成しても衝突しないのか。RFC4122規格とUUIDの性質。 ¦ 三 度の飯とエレクトロン 
 http://blog.katty.in/5124