Android examples for App:APK File
Gets the version name in the manifest file
import com.sun.istack.internal.Nullable; import android.content.Context; import android.content.pm.PackageManager; public class Main { /**/*ww w. j a v a 2s. c o m*/ * Gets the version name in the manifest file * * @param context * the context * @return version */ public static String getVersion(@Nullable Context context) { String version = "Unknown"; if (context == null) return version; try { version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException ex) { } return version; } }