Android Tablet Check isTabletDevice(Display d, Activity context)

Here you can find the source of isTabletDevice(Display d, Activity context)

Description

is Tablet Device

License

LGPL

Declaration

public static boolean isTabletDevice(Display d, Activity context) 

Method Source Code

//package com.java2s;
/**/*from   w w  w  .  j a v  a 2s . com*/
 * Copyright (c) 2012 Acrylic Goat Software
 * 
 * This software is subject to the provisions of the GNU Lesser General
 * Public License Version 3 (LGPL).  See LICENSE.txt for details.
 */

import android.app.Activity;
import android.util.Log;
import android.view.Display;

public class Main {
    public static boolean isTabletDevice(Display d, Activity context) {
        if (android.os.Build.VERSION.SDK_INT >= 11) { // honeycomb

            if (d.getWidth() < d.getHeight()) {
                //is portrait so return false
                return false;
            } else {
                //landscape so check width
                int w = d.getWidth();
                Log.d("DDGUtil", "width = " + w);
                if (w >= 900) {
                    return true;
                } else {
                    return false;
                }
            }

        }
        return false;
    }
}

Related

  1. isTablet(Configuration configuration)
  2. isTablet(Context context)
  3. isTabletDevice(Context activityContext)