Get Version Name with PackageManager : Version « Hardware « Android






Get Version Name with PackageManager

 
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;

/**
 * @author Ryan
 *
 */
public class Reflection {
  public static String getVersionName ( Context context ) {
    try {
      ComponentName comp = new ComponentName ( context, Reflection.class );
      PackageInfo pinfo = context.getPackageManager ().getPackageInfo ( comp.getPackageName (), 0 );
      return pinfo.versionName;
    } catch ( NameNotFoundException e ) {
      return null;
    }
  }

}

   
  








Related examples in the same category

1.Honeycomb version
2.Check Android build version
3.Get version information
4.Using VersionedGestureDetector
5.downloads and installs the latest version of our App
6.Get App Version Name
7.Get App Version Code
8.Get Package Version Code and Name
9.Android SDK version
10.Check for intallation, app name, app version, app version code
11.Get version number
12.Utility class providing array to int/long conversion for data received from devices through adb.
13.get Version Name
14.get Version Code
15.Byte value conversion