has Big Screen - Android User Interface

Android examples for User Interface:Screen Size

Description

has Big Screen

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.DisplayMetrics;

import android.view.WindowManager;

public class Main {
    private static Boolean _hasBigScreen = null;
    public static float displayDensity = 0.0F;

    public static boolean hasBigScreen(Context context) {
        boolean flag = true;
        if (_hasBigScreen == null) {
            boolean flag1;
            if ((0xf & context.getResources().getConfiguration().screenLayout) >= 3)
                flag1 = flag;/*from ww w  . ja va  2s .c o  m*/
            else
                flag1 = false;
            Boolean boolean1 = Boolean.valueOf(flag1);
            _hasBigScreen = boolean1;
            if (!boolean1.booleanValue()) {
                if (getDensity(context) <= 1.5F)
                    flag = false;
                _hasBigScreen = Boolean.valueOf(flag);
            }
        }
        return _hasBigScreen.booleanValue();
    }

    public static float getDensity(Context context) {
        if (displayDensity == 0.0)
            displayDensity = getDisplayMetrics(context).density;
        return displayDensity;
    }

    public static DisplayMetrics getDisplayMetrics(Context context) {
        DisplayMetrics displaymetrics = new DisplayMetrics();
        ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getMetrics(displaymetrics);
        return displaymetrics;
    }
}

Related Tutorials