Here you can find the source of getScreenSize(@Nonnull Context context)
Parameter | Description |
---|---|
context | The Context to use to retrieve the WindowManager |
@Nonnull public static int getScreenSize(@Nonnull Context context)
//package com.java2s; /*//w w w . j a v a2 s . co m * Copyright 2013 Luluvise Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import javax.annotation.Nonnull; import android.content.Context; import android.content.res.Configuration; public class Main { /** * Retrieves the screen size category for the device's default display from * the {@link Configuration} values. * * @param context * The {@link Context} to use to retrieve the * {@link WindowManager} * @return The retrieved screen size, can be one of * {@link Configuration#SCREENLAYOUT_SIZE_SMALL}, * {@link Configuration#SCREENLAYOUT_SIZE_NORMAL}, * {@link Configuration#SCREENLAYOUT_SIZE_LARGE}, * {@link Configuration#SCREENLAYOUT_SIZE_XLARGE} (<b>use the int 4 * for this configuration, constant available only from API 11</b>) */ @Nonnull public static int getScreenSize(@Nonnull Context context) { Configuration conf = context.getResources().getConfiguration(); return conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; } }