Example usage for android.content Context getResources

List of usage examples for android.content Context getResources

Introduction

In this page you can find the example usage for android.content Context getResources.

Prototype

public abstract Resources getResources();

Source Link

Document

Returns a Resources instance for the application's package.

Usage

From source file:Main.java

public static String getString(Context context, int id) {
    return context.getResources().getString(id);
}

From source file:Main.java

public static boolean isLandscape(Context context) {
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        return true;
    }//from  www .j  ava  2  s. c o  m
    return false;
}

From source file:Main.java

/**
 * get width pixels/*from w  w w .j  a  v  a  2s. c o m*/
 *
 * @param context
 * @return
 */
public static float getWidthPixels(Context context) {
    return context.getResources().getDisplayMetrics().widthPixels;
}

From source file:Main.java

public static int getCircleDp(Context mContext) {
    if (mContext.getResources().getDisplayMetrics().densityDpi <= DisplayMetrics.DENSITY_HIGH) {
        return 10;
    } else {//w  ww.  j  a  va2 s.  c  o  m
        return 15;
    }
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    return (int) (context.getResources().getDisplayMetrics().heightPixels + 0.5);
}

From source file:Main.java

public static int getNoneDp(Context mContext) {
    if (mContext.getResources().getDisplayMetrics().densityDpi <= DisplayMetrics.DENSITY_HIGH) {
        return 6;
    } else {/*from   w w w  .  ja  va 2s. c  o m*/
        return 7;
    }
}

From source file:Main.java

public static int getIconSize(Context context) {
    return (int) context.getResources().getDimension(android.R.dimen.app_icon_size);
}

From source file:Main.java

/**
 * get scale density//  w  w  w .j  a  v  a 2  s  .  c o  m
 *
 * @param context
 * @return
 */
public static float getScaleDensity(Context context) {
    return context.getResources().getDisplayMetrics().scaledDensity;
}

From source file:Main.java

public static boolean isScreenOrientationLandscape(Context context) {

    return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

}

From source file:Main.java

public static String getResourceString(Context context, int id) {
    return context.getResources().getString(id);
}