Example usage for android.view Display getHeight

List of usage examples for android.view Display getHeight

Introduction

In this page you can find the example usage for android.view Display getHeight.

Prototype

@Deprecated
public int getHeight() 

Source Link

Usage

From source file:org.alfresco.mobile.android.ui.utils.UIUtils.java

/**
 * Retrieve screen dimension./*  www  . ja  va 2s . c o  m*/
 * 
 * @param activity
 * @return
 */
public static int[] getScreenDimension(FragmentActivity activity) {
    int width = 0;
    int height = 0;

    Display display = activity.getWindowManager().getDefaultDisplay();
    if (AndroidVersion.isHCMR2OrAbove()) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
        height = size.y;
    } else {
        width = display.getWidth(); // deprecated
        height = display.getHeight(); // deprecated
    }

    return new int[] { width, height };
}

From source file:org.kontalk.util.SystemUtils.java

@SuppressWarnings("deprecation")
public static Point getDisplaySize(Context context) {
    Point displaySize = null;/*from w  ww .  j  a v  a 2s. co m*/
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    if (display != null) {
        displaySize = new Point();
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
            displaySize.set(display.getWidth(), display.getHeight());
        } else {
            display.getSize(displaySize);
        }
    }

    return displaySize;
}

From source file:com.dm.material.dashboard.candybar.helpers.ViewHelper.java

public static Point getRealScreenSize(@NonNull Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        display.getRealSize(size);/*from   www.j a  v a  2 s  .  co m*/
    } else {
        try {
            size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
            size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
        } catch (Exception e) {
            size.x = display.getWidth();
            size.y = display.getHeight();
        }
    }
    return size;
}

From source file:Main.java

public static Point getSize(Display display) {
    if (Build.VERSION.SDK_INT >= 17) {
        Point outPoint = new Point();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getRealMetrics(metrics);
        outPoint.x = metrics.widthPixels;
        outPoint.y = metrics.heightPixels;
        return outPoint;
    }/*from ww w.ja  va 2 s  . c  o m*/
    if (Build.VERSION.SDK_INT >= 14) {
        Point outPoint = getRealSize(display);
        if (outPoint != null)
            return outPoint;
    }
    Point outPoint = new Point();
    if (Build.VERSION.SDK_INT >= 13) {
        display.getSize(outPoint);
    } else {
        outPoint.x = display.getWidth();
        outPoint.y = display.getHeight();
    }
    return outPoint;
}

From source file:com.sxnyodot.uefqvmio207964.Util.java

static boolean m932a(Context context) {
    DisplayMetrics displayMetrics = context.getApplicationContext().getResources().getDisplayMetrics();
    Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
    int width = defaultDisplay.getWidth();
    int height = defaultDisplay.getHeight();
    float f = displayMetrics.density;
    if (((float) width) / f < 600.0f || ((float) height) / f < 600.0f) {
        return false;
    }//from ww w.  j  a  va 2s .c o m
    return true;
}

From source file:Main.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static Point getFullDisplaySize(Context context) {
    Point point = new Point();

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    Display display = wm.getDefaultDisplay();
    Method mGetRawH = null, mGetRawW = null;

    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);/*w w  w  .j  a v  a 2  s . co m*/

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        display.getRealMetrics(outMetrics);
        point.x = outMetrics.widthPixels;
        point.y = outMetrics.heightPixels;
    } else {
        try {
            mGetRawH = Display.class.getMethod("getRawHeight");
            mGetRawW = Display.class.getMethod("getRawWidth");
            point.x = (Integer) mGetRawW.invoke(display);
            point.y = (Integer) mGetRawH.invoke(display);
        } catch (Exception e) {
            display.getMetrics(outMetrics);
            point.x = display.getWidth();
            point.y = display.getHeight();
            e.printStackTrace();
        }
    }

    return point;
}

From source file:com.sxnyodot.uefqvmio207964.Util.java

static String m965k(Context context) {
    String str = "";
    if (context == null) {
        return str;
    }/* w  w  w  .  j a  v a  2s  .c o  m*/
    Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
    if (VERSION.SDK_INT < NETWORK_TYPE_LTE) {
        return "" + defaultDisplay.getWidth() + "_" + defaultDisplay.getHeight();
    }
    Point point = new Point();
    defaultDisplay.getSize(point);
    return point.x + "_" + point.y;
}

From source file:io.github.hidroh.materialistic.AppUtils.java

public static int getDisplayHeight(Context context) {
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point point = new Point();
        display.getSize(point);/*from   w  w  w . j a v a2s .c  om*/
        return point.y;
    } else {
        //noinspection deprecation
        return display.getHeight();
    }
}

From source file:org.brandroid.openmanager.fragments.DialogHandler.java

public static void showAboutDialog(final Context mContext) {
    LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = li.inflate(R.layout.about, null);

    String sVersionInfo = "";
    try {//from  w w  w.j  a  v a  2 s  .  c  o  m
        PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
        sVersionInfo += pi.versionName;
        if (!pi.versionName.contains("" + pi.versionCode))
            sVersionInfo += " (" + pi.versionCode + ")";
        if (OpenExplorer.IS_DEBUG_BUILD)
            sVersionInfo += " *debug*";
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String sBuildTime = "";
    try {
        sBuildTime = SimpleDateFormat.getInstance()
                .format(new Date(new ZipFile(
                        mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), 0).sourceDir)
                                .getEntry("classes.dex").getTime()));
    } catch (Exception e) {
        Logger.LogError("Couldn't get Build Time.", e);
    }

    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    Display d = wm.getDefaultDisplay();
    String sHardwareInfo = "Display:\n";
    sHardwareInfo += "Size: " + d.getWidth() + "x" + d.getHeight() + "\n";
    if (dm != null)
        sHardwareInfo += "Density: " + dm.density + "\n";
    sHardwareInfo += "Rotation: " + d.getRotation() + "\n\n";
    sHardwareInfo += getNetworkInfo(mContext);
    sHardwareInfo += getDeviceInfo();
    ((TextView) view.findViewById(R.id.about_hardware)).setText(sHardwareInfo);

    final String sSubject = "Feedback for OpenExplorer " + sVersionInfo;
    OnClickListener email = new OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            //intent.addCategory(Intent.CATEGORY_APP_EMAIL);
            intent.putExtra(android.content.Intent.EXTRA_TEXT, "\n" + getDeviceInfo());
            intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "brandroid64@gmail.com" });
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, sSubject);
            mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.s_chooser_email)));
        }
    };
    OnClickListener viewsite = new OnClickListener() {
        public void onClick(View v) {
            mContext.startActivity(
                    new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://brandroid.org/open/")));
        }
    };
    view.findViewById(R.id.about_email).setOnClickListener(email);
    view.findViewById(R.id.about_email_btn).setOnClickListener(email);
    view.findViewById(R.id.about_site).setOnClickListener(viewsite);
    view.findViewById(R.id.about_site_btn).setOnClickListener(viewsite);
    final View mRecentLabel = view.findViewById(R.id.about_recent_status_label);
    final WebView mRecent = (WebView) view.findViewById(R.id.about_recent);
    final OpenChromeClient occ = new OpenChromeClient();
    occ.mStatus = (TextView) view.findViewById(R.id.about_recent_status);
    mRecent.setWebChromeClient(occ);
    mRecent.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            occ.mStatus.setVisibility(View.GONE);
            mRecent.setVisibility(View.GONE);
            mRecentLabel.setVisibility(View.GONE);
        }
    });
    mRecent.setBackgroundColor(Color.TRANSPARENT);
    mRecent.loadUrl("http://brandroid.org/open/?show=recent");

    ((TextView) view.findViewById(R.id.about_version)).setText(sVersionInfo);
    if (sBuildTime != "")
        ((TextView) view.findViewById(R.id.about_buildtime)).setText(sBuildTime);
    else
        ((TableRow) view.findViewById(R.id.row_buildtime)).setVisibility(View.GONE);

    fillShortcutsTable((TableLayout) view.findViewById(R.id.shortcuts_table));

    final View tab1 = view.findViewById(R.id.tab1);
    final View tab2 = view.findViewById(R.id.tab2);
    final View tab3 = view.findViewById(R.id.tab3);
    ((Button) view.findViewById(R.id.btn_recent)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.VISIBLE);
            tab2.setVisibility(View.GONE);
            tab3.setVisibility(View.GONE);
        }
    });
    ((Button) view.findViewById(R.id.btn_hardware)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.GONE);
            tab2.setVisibility(View.VISIBLE);
            tab3.setVisibility(View.GONE);
        }
    });
    ((Button) view.findViewById(R.id.btn_shortcuts)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.GONE);
            tab2.setVisibility(View.GONE);
            tab3.setVisibility(View.VISIBLE);
        }
    });

    AlertDialog mDlgAbout = new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setView(view)
            .create();

    mDlgAbout.getWindow().getAttributes().windowAnimations = R.style.SlideDialogAnimation;
    mDlgAbout.getWindow().getAttributes().alpha = 0.9f;

    mDlgAbout.show();
}

From source file:com.apptentive.android.sdk.util.Util.java

public static Point getScreenSize(Context context) {
    Point ret = new Point();
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    // TODO: getWidth(), getHeight(), and getOrientation() are deprecated in API 13 in favor of getSize() and getRotation().
    ret.set(display.getWidth(), display.getHeight());
    return ret;/*from  w w  w .  ja va2s  . c om*/
}