Android Context Check isTablet(Context ctx)

Here you can find the source of isTablet(Context ctx)

Description

is Tablet

License

Open Source License

Declaration

public static boolean isTablet(Context ctx) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Created by Carlos Yaconi//from  ww w  .j  av  a  2  s  .c  o  m
 * Copyright 2012 Fork Ltd. All rights reserved.
 * License: GPLv3
 * Full license at "/LICENSE"
 ******************************************************************************/

import android.content.Context;

import android.util.DisplayMetrics;

public class Main {
    public static boolean isTablet(Context ctx) {
        try {
            DisplayMetrics dm = ctx.getResources().getDisplayMetrics();
            float screenWidth = dm.widthPixels / dm.xdpi;
            float screenHeight = dm.heightPixels / dm.ydpi;
            double size = Math.sqrt(Math.pow(screenWidth, 2)
                    + Math.pow(screenHeight, 2));
            return size >= 6;
        } catch (Throwable t) {
            return false;
        }
    }
}

Related

  1. isPermissionGranted(Context ctx)
  2. isSensAppInstalled(Context context)
  3. isServiceRunning(Context ctx, String className)
  4. isServiceRunning(Context ctx, String className)
  5. isSystemApplication(Context context, String packageName)
  6. isTablet(final Context context)
  7. isThemeInstalled(Context c, String theme)
  8. isUpdateAvailable(Context paramContext, String paramString)
  9. isValidSigningKey(final Context context, final String certificateToCheckAgainst)