Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

import android.content.pm.PackageInfo;

import android.content.pm.PackageManager.NameNotFoundException;

import android.os.Build;

public class Main {
    public static String getBuildInfo(Context context) {
        // get app version info
        String appVersion = "";
        PackageInfo pInfo;
        try {
            pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            appVersion = pInfo.versionName + " (" + pInfo.versionCode + ")\n";
        } catch (NameNotFoundException e) {
        }

        String board = "Board: " + Build.BOARD + "\n";
        String bootloader = "Bootloader: " + Build.BOOTLOADER + "\n";
        String brand = "Brand: " + Build.BRAND + "\n";
        String device = "Device: " + Build.DEVICE + "\n";
        String display = "Display: " + Build.DISPLAY + "\n";
        String product = "Product: " + Build.PRODUCT + "\n";
        String model = "Model: " + Build.MODEL + "\n";
        String manufacturer = "Manufacturer: " + Build.MANUFACTURER + "\n";

        return appVersion + board + bootloader + brand + device + display + product + model + manufacturer;
    }
}