List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
public static int getDrawableResource(Context context, @NonNull String resource) { return context.getResources().getIdentifier(resource, "drawable", context.getPackageName()); }
From source file:Main.java
public static int getDrawableIdByName(Context context, String drawableName) { return context.getResources().getIdentifier(drawableName, "drawable", context.getPackageName()); }
From source file:Main.java
public static int getVersionCode(Context context) { try {/*from w ww.ja va2 s .com*/ PackageInfo pkg = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pkg.versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static int getVersionCode(Context context) { try {// w ww .ja v a 2 s . c o m PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static String getAppVersionName(Context context) { try {//from ww w . j a va 2 s . c o m PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return ""; }
From source file:Main.java
static public String getString(Context context, String name) { int identifier = context.getResources().getIdentifier(name, "string", context.getPackageName()); if (identifier > 0) { return context.getResources().getString(identifier); }//from ww w .j a v a 2s .c om return ""; }
From source file:Main.java
public static String GetVersion(Context context) { try {/* w w w. j a va2 s.co m*/ PackageInfo manager = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return manager.versionName; } catch (PackageManager.NameNotFoundException e) { return "Unknown"; } }
From source file:Main.java
public static String getAppVersionName(Context context) { try {/*from ww w . j av a 2 s .c om*/ PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionName; } catch (Exception e) { // ignore missing data } return "unknown"; }
From source file:Main.java
public static int getValuesId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "values", paramContext.getPackageName()); }
From source file:Main.java
public static int getResStyle(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "style", paramContext.getPackageName()); }