Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Build;

public class Main {
    /**
     * Retrieves the information(deviceId, sim serial number etc) of the device on which app is running 
     * 
     * @return the deviceID, if no deviceID is available the Android build MODEL is returned.
     */
    public static String getDeviceName() {
        final String deviceName;

        String manufacturer = "" + Build.MANUFACTURER;
        String model = Build.MODEL;

        if (model.startsWith(manufacturer)) {
            deviceName = model;
        } else {
            deviceName = manufacturer + " " + model;
        }

        return deviceName;
    }
}