Android Question

How to detect device is Android phone or Android tablet?

I have two apps for android tablets and android phones. For tablet app i set android:minSdkVersion="11". But nowadays android phones like Galaxy S3 has android versiyon 4.0.4 so S3 users can download my tablet app from Google Play Store. I want to warn phone users to download phone app when they install tablet app. vice versa for tablet users download tablet app when they run phone app.

Is there any easy way to detect the device type?


I found solution on this link: http://developer.android.com/guide/practices/screens-distribution.html

In your manifest file you can declare screen feature for handset and tablets then Google Play decides download permissions for both phone and tablet.

Answer Source

Use this:

public static boolean isTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK)
            >= Configuration.SCREENLAYOUT_SIZE_LARGE;

which will return true if the device is operating on a large screen.

Some other helpful methods can be found here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download