List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
public static String getVersionName(Context context) { try {//w w w .j a v a 2s . co m PackageInfo manager = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return manager.versionName; } catch (Exception e) { return "Unknown"; } }
From source file:Main.java
public static void clearActivityTask(final Context context) { Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(i);/*from w w w . j a va2 s .c om*/ ((Activity) context).finish(); }
From source file:Main.java
public static String getVersionName(Context context) { try {// w w w .ja va2 s . c o m PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionName; } catch (PackageManager.NameNotFoundException ex) { ex.printStackTrace(); } return null; }
From source file:Main.java
public static int getAppVersionCode(Context context) { try {//from w w w.j a v a2s. co m PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 1; }
From source file:Main.java
public static String getVersionName(Context context) { try {/*from w w w . j a va 2 s.c om*/ PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionName; } catch (NameNotFoundException e) { return ""; } }
From source file:Main.java
public static int getAnimId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "anim", paramContext.getPackageName()); }
From source file:Main.java
public static int getResourceIdByStr(Context context, String resName, String defType) { return context.getResources().getIdentifier(resName, defType, context.getPackageName()); }
From source file:Main.java
public static int getVersionCode(Context context) { try {// ww w .ja v a2 s. c om PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (NameNotFoundException e) { return 0; } }
From source file:Main.java
public static String getPackageVersionName(Context context) throws PackageManager.NameNotFoundException { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; }
From source file:Main.java
public static int getVersionCode(Context context) { try {//from w ww . j a va 2s .c o m PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { } return -1; }