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 {// ww w . ja v a 2s. c o m return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); throw new RuntimeException("get versionCode Exception(RuntimeException)"); } }
From source file:Main.java
private static int getLocalVersionCode(Context context) { try {/*from w w w .j a va 2s . com*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return -1; } }
From source file:Main.java
public static int getVersionCode(Context context) { try {/*from w w w . j a v a2 s . c om*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); throw new RuntimeException("get versionCode Exception(RuntimeException)"); } }
From source file:Main.java
public static PackageInfo getPackageInfo(Context context) { try {/*from ww w .j a v a2 s .c om*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { // Should never happen. throw new RuntimeException(e); } }
From source file:Main.java
public static int getDrawableId(Context context, String resName) { return context.getResources().getIdentifier(resName, "drawable", context.getPackageName()); }
From source file:Main.java
/** * Get an identifier by string name/* www . j ava 2 s .c om*/ * @param context The context * @param name The identifier name * @return The identifier */ public static int getDrawableIdentifier(Context context, String name) { return context.getResources().getIdentifier(name, "drawable", context.getPackageName()); }
From source file:Main.java
private static int getVersionCode(Context context) { try {/*from w ww .j a v a2 s . c om*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return -1; }
From source file:Main.java
public static void DEBUG(Context c) { try {/* w ww . j a v a2s . c o m*/ debug = (c.getPackageManager().getApplicationInfo(c.getPackageName(), 0).flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:Main.java
public static int getVersionCode(Context context) { try {//from www. j a v a2 s. com return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (Exception e) { Log.e(TAG, "Cannot find package and its version info."); return -1; } }
From source file:Main.java
public static String getDefaultRenderName(Context context) { String s;/*from www .j a va 2s .c o m*/ try { s = context.getSharedPreferences(context.getPackageName(), 1).getString("default_render_name", null); } catch (Exception exception) { exception.printStackTrace(); return null; } return s; }