Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.telephony.TelephonyManager;
import android.text.TextUtils;

import java.util.UUID;

public class Main {

    public static String getDeviceId(TelephonyManager tm) {
        String id = tm.getSubscriberId();
        if (TextUtils.isEmpty(id)) {
            id = tm.getDeviceId();
        }
        if (TextUtils.isEmpty(id)) {
            id = UUID.randomUUID().toString();
        }
        return id;
    }
}