Return true if device is at least 480x640 dp, otherwise false. - Android Android OS

Android examples for Android OS:OS Version

Description

Return true if device is at least 480x640 dp, otherwise false.

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.Configuration;
import android.support.annotation.NonNull;

public class Main {
    /** Return true if device is at least 480x640 dp, otherwise false. */
    public static boolean isTablet(@NonNull Context context) {
        return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    }/*from w  ww  .  java 2s. c o m*/
}

Related Tutorials