Example usage for android.util DisplayMetrics DENSITY_400

List of usage examples for android.util DisplayMetrics DENSITY_400

Introduction

In this page you can find the example usage for android.util DisplayMetrics DENSITY_400.

Prototype

int DENSITY_400

To view the source code for android.util DisplayMetrics DENSITY_400.

Click Source Link

Document

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Usage

From source file:Main.java

/**
 * The screen density expressed as dots-per-inch.
 * @param density_dpi "densityDpi"//from  w  w w . j  av  a 2 s. co  m
 */
public static String getDensityDPIStr(int density_dpi) {
    switch (density_dpi) {
    case DisplayMetrics.DENSITY_LOW://120
        return "DENSITY_LOW";
    case DisplayMetrics.DENSITY_MEDIUM://160
        return "DENSITY_MEDIUM/DENSITY_DEFAULT";
    //case DisplayMetrics.DENSITY_DEFAULT://160
    //    return "DENSITY_DEFAULT";
    case DisplayMetrics.DENSITY_TV://213
        return "DENSITY_TV";
    case DisplayMetrics.DENSITY_HIGH://240
        return "DENSITY_HIGH";
    case DisplayMetrics.DENSITY_280://280
        return "DENSITY_280";
    case DisplayMetrics.DENSITY_XHIGH://320
        return "DENSITY_XHIGH";
    case DisplayMetrics.DENSITY_360://360
        return "DENSITY_360";
    case DisplayMetrics.DENSITY_400://400
        return "DENSITY_400";
    case DisplayMetrics.DENSITY_420://420
        return "DENSITY_420";
    case DisplayMetrics.DENSITY_XXHIGH://480
        return "DENSITY_XXHDPI";
    case DisplayMetrics.DENSITY_560://560
        return "DENSITY_560";
    case DisplayMetrics.DENSITY_XXXHIGH://640
        return "DENSITY_XXXHDPI";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

public static String getDensity(Context ctx) {
    String densityStr = null;/*from  ww  w.j a  v a  2s  . c o  m*/
    final int density = ctx.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        densityStr = "LDPI";
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        densityStr = "MDPI";
        break;
    case DisplayMetrics.DENSITY_TV:
        densityStr = "TVDPI";
        break;
    case DisplayMetrics.DENSITY_HIGH:
        densityStr = "HDPI";
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        densityStr = "XHDPI";
        break;
    case DisplayMetrics.DENSITY_400:
        densityStr = "XMHDPI";
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXXHIGH:
        densityStr = "XXXHDPI";
        break;
    }
    return densityStr;
}

From source file:count.ly.messaging.DeviceInfo.java

/**
 * Maps the current display density to a string constant.
 * @param context context to use to retrieve the current display metrics
 * @return a string constant representing the current display density, or the
 *         empty string if the density is unknown
 *///from  w w  w  .j a  va  2s . c o  m
static String getDensity(final Context context) {
    String densityStr = "";
    final int density = context.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        densityStr = "LDPI";
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        densityStr = "MDPI";
        break;
    case DisplayMetrics.DENSITY_TV:
        densityStr = "TVDPI";
        break;
    case DisplayMetrics.DENSITY_HIGH:
        densityStr = "HDPI";
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        densityStr = "XHDPI";
        break;
    case DisplayMetrics.DENSITY_400:
        densityStr = "XMHDPI";
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXXHIGH:
        densityStr = "XXXHDPI";
        break;
    }
    return densityStr;
}

From source file:ly.count.android.sdk.DeviceInfo.java

/**
 * Maps the current display density to a string constant.
 * @param context context to use to retrieve the current display metrics
 * @return a string constant representing the current display density, or the
 *         empty string if the density is unknown
 *///w w w  .jav  a2 s. co  m
static String getDensity(final Context context) {
    String densityStr = "";
    final int density = context.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        densityStr = "LDPI";
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        densityStr = "MDPI";
        break;
    case DisplayMetrics.DENSITY_TV:
        densityStr = "TVDPI";
        break;
    case DisplayMetrics.DENSITY_HIGH:
        densityStr = "HDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_260:
    //    densityStr = "XHDPI";
    //    break;
    case DisplayMetrics.DENSITY_280:
        densityStr = "XHDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_300:
    //    densityStr = "XHDPI";
    //    break;
    case DisplayMetrics.DENSITY_XHIGH:
        densityStr = "XHDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_340:
    //    densityStr = "XXHDPI";
    //    break;
    case DisplayMetrics.DENSITY_360:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_400:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_420:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_560:
        densityStr = "XXXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXXHIGH:
        densityStr = "XXXHDPI";
        break;
    default:
        densityStr = "other";
        break;
    }
    return densityStr;
}

From source file:ly.count.android.api.DeviceInfoTests.java

public void testGetDensity() {
    Context mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_LOW);
    assertEquals("LDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_MEDIUM);
    assertEquals("MDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_TV);
    assertEquals("TVDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_HIGH);
    assertEquals("HDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XHIGH);
    assertEquals("XHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXHIGH);
    assertEquals("XXHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXXHIGH);
    assertEquals("XXXHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_400);
    assertEquals("XMHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(0);
    assertEquals("", DeviceInfo.getDensity(mockContext));
}