Example usage for android.content.res Resources getIdentifier

List of usage examples for android.content.res Resources getIdentifier

Introduction

In this page you can find the example usage for android.content.res Resources getIdentifier.

Prototype

public int getIdentifier(String name, String defType, String defPackage) 

Source Link

Document

Return a resource identifier for the given resource name.

Usage

From source file:Main.java

public static int getResIDByResName(Activity activity, String iconName) {
    Resources resources = activity.getResources();
    int indentify = resources.getIdentifier(activity.getPackageName() + ":drawable/" + iconName, null, null);
    return indentify;
}

From source file:Main.java

public static int getPeripheralsLeftIconResourceId(Resources resources, String drawableName, Context context) {
    return resources.getIdentifier(photo + drawableName.toLowerCase(), "drawable", context.getPackageName());
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    int height = resources.getDimensionPixelSize(resourceId);
    return height;
}

From source file:Main.java

public static int getBottomBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }// ww w .  j a  va 2 s  . c  om
    return 0;
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelOffset(resourceId);
    }/*from  w  ww  .  ja va2 s . c o  m*/
    return 0;
}

From source file:Main.java

public static int getNaviBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }/*from   ww w  .  ja  va  2 s  . c  o m*/
    return 0;
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }//  ww  w  . j  a  va2s  . c  om
    return 0;
}

From source file:Main.java

public static int getStatusBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    int height = resources.getDimensionPixelSize(resourceId);
    Log.v("dbw", "Status height:" + height);
    return height;
}

From source file:Main.java

public static int getNavigationBarrH(Context c) {
    Resources resources = c.getResources();
    int identifier = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    return resources.getDimensionPixelOffset(identifier);
}

From source file:Main.java

public static int getMinimumScreenBrightnessSetting(Context context) {
    final Resources res = Resources.getSystem();
    int id = res.getIdentifier("config_screenBrightnessSettingMinimum", "integer", "android"); // API17+
    if (id == 0)/*w w  w  . j  a  v a2  s .  c  o  m*/
        id = res.getIdentifier("config_screenBrightnessDim", "integer", "android"); // lower API levels
    if (id != 0) {
        try {
            return res.getInteger(id);
        } catch (Resources.NotFoundException e) {
            // ignore
        }
    }
    return 0;
}