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;

import android.util.Log;

public class Main {
    public static final String TAG = "kae.util.AndroidUtils";

    public static String getApplicationVersion(Context ctx) {
        try {
            return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            Log.d(TAG, "", e);
            return null;
        }
    }
}