List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static String getCountry(Context context) { Locale locale = context.getResources().getConfiguration().locale; String country = locale.getDisplayCountry(); return country; }
From source file:Main.java
public static int getStatusBarHeight(Context context) { int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); return context.getResources().getDimensionPixelSize(resourceId); }
From source file:Main.java
public static int convertDpToPixel(float dp, Context context) { return (int) (dp * context.getResources().getDisplayMetrics().density + 0.5f); }
From source file:Main.java
/** * check if the phone use Chinese as first language * @param context// ww w . java 2s . c o m * @return */ public static boolean isChineseLaguage(Context context) { if (context.getResources().getConfiguration().locale.getCountry().equals("CN") || context.getResources().getConfiguration().locale.getCountry().equals("TW")) { return true; } else { return false; } }
From source file:Main.java
public static String[] getStringArray(Context context, int resId) { return context.getResources().getStringArray(resId); }
From source file:Main.java
public static int convertPxToDp(Context context, int px) { float d = context.getResources().getDisplayMetrics().density; return (int) ((px / d) + 0.5); }
From source file:Main.java
public static int getStringId(Context context, String name) { return context.getResources().getIdentifier(name, "string", context.getPackageName()); }
From source file:Main.java
public static String getLanguage(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getDisplayLanguage(); return language; }
From source file:Main.java
public static int getResourceColor(Context context, int resource) { return context.getResources().getColor(resource); }
From source file:Main.java
public static boolean isLandscape(@NonNull Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }