Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static String getVersionName(Activity activity) { PackageManager packageManager = activity.getPackageManager(); PackageInfo packInfo; try { packInfo = packageManager.getPackageInfo(activity.getPackageName(), 0); return packInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return "1.0"; } } }