Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Formatter;

import android.nfc.Tag;

public class Main {
    public static String getTagUuid(Tag tag) {
        byte[] tagIDBytes = tag.getId();
        return mBytesToHexString(tagIDBytes);
    }

    private static String mBytesToHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * 2);

        Formatter formatter = new Formatter(sb);
        for (byte b : bytes) {
            formatter.format("%02x", b);
        }

        return "0x" + sb.toString().toUpperCase();
    }
}