Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.pm.PackageManager;

public class Main {
    private static Context sContext;

    public static int getAppVersion() {
        try {
            return sContext.getPackageManager().getPackageInfo(sContext.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            // should never happen...

            throw new RuntimeException("Could not get package name: " + e);
        }
    }
}