Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:41:25+00:00 2026-05-31T22:41:25+00:00

I would like to get to detect whether the given device is a tablet

  • 0

I would like to get to detect whether the given device is a tablet or phone in android.I have tried the two in the simulator but none worked. Both are here:

First

if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) 
{
    //code
}

Second

    private boolean isTabletDevice() 
{         
    if (android.os.Build.VERSION.SDK_INT >= 11) 
    { 
    // honeycomb                    
    // test screen size, use reflection because isLayoutSizeAtLeast is only available since 11     
    Configuration con = getResources().getConfiguration();              
    try {                     
            Method mIsLayoutSizeAtLeast = con.getClass().getMethod("isLayoutSizeAtLeast");    
            Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con, 0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE    
            return r;              
        } catch (Exception x)
        {    
            return false;          
        }             
    }            
    return false;                   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:41:26+00:00Added an answer on May 31, 2026 at 10:41 pm

    Try this code. You can get the screen inches

        String inputSystem;
        inputSystem = android.os.Build.ID;
        Log.d("hai",inputSystem);
        Display display = getWindowManager().getDefaultDisplay(); 
        int width = display.getWidth();  // deprecated
        int height = display.getHeight();  // deprecated
        Log.d("hai",width+"");
        Log.d("hai",height+"");
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        double x = Math.pow(width/dm.xdpi,2);
        double y = Math.pow(height/dm.ydpi,2);
        double screenInches = Math.sqrt(x+y);
        Log.d("hai","Screen inches : " + screenInches+"");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this issue working but i would like to know if there is
I would like to be able to detect in cocoa(or actionscript, but cocoa preferably)
Given the source code of a Python file, I would like to detect all
I would like to get the dimensions (coordinates) for all the HTML elements of
I would like to get the most out of working in cch or tcsh
I would like to get a reference to all objects in the Java heap,
I would like to get some information on list of points that needs to
I would like to get contents of some stream or project I can find
I would like to get the AssemblyCompany attribute from a WinForm project inside of
I would like to get the final SQL query, with parameter values bound (replaced)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.