Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android仅在手机中支持人像_Android_Hybrid Mobile App - Fatal编程技术网

Android仅在手机中支持人像

Android仅在手机中支持人像,android,hybrid-mobile-app,Android,Hybrid Mobile App,Home让android应用程序只能在移动设备上以纵向模式运行,而在平板电脑上,它允许纵向和横向两种方向? 提前感谢在清单中,为所有活动设置此选项: <activity android:name=".YourActivity" android:configChanges="orientation" android:screenOrientation="portrait"/> 首先在活动或slpash屏幕中检查应用程序必须在哪个设备上运行 在mainActivity或

Home让android应用程序只能在移动设备上以纵向模式运行,而在平板电脑上,它允许纵向和横向两种方向?
提前感谢

在清单中,为所有活动设置此选项:

<activity android:name=".YourActivity"
    android:configChanges="orientation"
    android:screenOrientation="portrait"/>

首先在活动或slpash屏幕中检查应用程序必须在哪个设备上运行

在mainActivity或启动屏幕上检查以下代码

Intent intent;
if (isTablet(DeciderActivity.this)) 
{
   // for Tablet
   intent = new Intent(this, TabletSplashActivity.class);
   startActivity(intent);
} 
else 
{
  // for Phone
  intent = new Intent(this, PhoneSplashActivity.class);
  startActivity(intent);
}
请声明isTablet方法

public static boolean isTablet() {

        DisplayMetrics metrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        float yInches = metrics.heightPixels / metrics.ydpi;
        float xInches = metrics.widthPixels / metrics.xdpi;
        double diagonalInches = Math.sqrt(xInches * xInches + yInches * yInches);

        if (diagonalInches >= 7) {
                // 7inch device or bigger
                return true;
            } else {
                // smaller device
                return false;
            }
        }
我希望这对您有用,我的代码运行良好。

检查此项和此项