如何检测设备是Android手机或Android平板电脑?平板、检测设备、电脑、手机

2023-09-12 21:34:04 作者:柠檬色的秋千

我有两个应用程序为Android平板电脑和Android手机。对于平板电脑的应用程序我设置安卓的minSdkVersion =11。但现在的Andr​​oid手机一样的Galaxy S3已经在Android versiyon 4.0.4使S3的用户可以从谷歌平板电脑我的应用Play商店。我想提醒手机用户下载手机应用程序在安装平板电脑的应用程序。反之为平板电脑用户下载应用程序,平板电脑,当他们运行的手机应用程序。

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?

编辑:

我发现这个链接的解决方案:http://developer.android.com/guide/practices/screens-distribution.html

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.

推荐答案

使用这样的:

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

这将返回true,如果该设备运行在大屏幕上。

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

Some其他有用的方法可以在这里找到 。