gpt4 book ai didi

java - 无法锁定方向;可能的修复?

转载 作者:行者123 更新时间:2023-11-30 00:20:00 25 4
gpt4 key购买 nike

默认情况下仅尝试将方向设置为 Portrait。为此,我添加了:

android:configChanges="orientation"
android:screenOrientation="portrait"

但是,应用程序会在倾斜时自动旋转到横向 模式。此外,即使在手机 Settings 中将方向锁定为纵向,应用也会在倾斜时转为 Landscape 模式。

这是 Manifest.xml 文件:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.browser.codedady">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<!-- Browser Main Tab -->

<activity
android:name=".Activity_Main"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

<action android:name="readLater" />
<action android:name="bookmarks" />
<action android:name="history" />
<action android:name="pass" />
</intent-filter>
<intent-filter
android:icon="@mipmap/ic_launcher"
android:label="@string/app_websearch">
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

<!-- Other activities -->

<activity
android:name=".about.About_activity"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_intro"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_app"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_data"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_searchMain"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_close"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_start"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />
<activity
android:name=".helper.Activity_settings_search"
android:configChanges="orientation|screenSize"
android:launchMode="singleInstance" />

<!-- Intents -->

<activity
android:name=".helper.Activity_intent"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<action android:name="android.intent.action.VIEW" />

<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>

<!-- More stuff -->

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.browser.codedady.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

<activity
android:name=".Home"
android:label="@string/title_activity_home"
android:theme="@style/AppTheme" />

</application>

</manifest>

可能是什么原因造成的,如何解决这个问题?

最佳答案

为每个 Activity 添加 screenOrientation = "portrait",如下所示:

<activity
android:name=".MainActivity"
android:screenOrientation="portrait" />

确保您的 Java 代码不会意外改变 Activity 的方向。 Configchanges 没有将它设置为默认值,它要求 Java 负责设置它。如果他们不做任何其他事情,请将其删除。 See android docs here (搜索“android:configChanges”)

关于java - 无法锁定方向;可能的修复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46501480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com