Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.security.SecureRandom;

import android.annotation.SuppressLint;

public class Main {
    /**
     * Generates a new random app ID. Currently the App id consists of 8
     * hexadecimal digits generated based on the Android SecureRandom class.
     * 
     * @return
     */
    @SuppressLint("TrulyRandom")
    public static String generateAppId() {
        SecureRandom sr = new SecureRandom();
        byte[] random = new byte[4];
        sr.nextBytes(random);
        return String.format("%02x%02x%02x%02x", random[0], random[1], random[2], random[3]);
    }
}