为 Android 禁用 Multi-window 功能 N 不适用于 activity

Disabling Multi-window feature for Android N not working for an activity

我想在我的应用程序中禁用对 activity 的多 window 支持。 我已在我的清单中将 resizeableActivity 设置为 false,但是当我长按最近使用的应用程序图标时,该应用程序仍处于 multi-window 模式。以下是我的清单:

<activity
    android:name=".MainActivity"
    android:resizeableActivity="false"
    android:excludeFromRecents="true"
    android:icon="@drawable/ic_launcher_home"
    android:theme="@style/AppThemeV3.CustomToolbar">
</activity>

根据 documentation:

android:resizeableActivity=["true" | "false"]

If the attribute is set to false, the activity does not support multi-window mode. If this value is false, and the user attempts to launch the activity in multi-window mode, the activity takes over the full screen.

我还尝试在清单中的应用程序级别将此属性设置为 false,但它仍然以 multi-window 模式启动。如果有人指出我做错了什么,我们将不胜感激?

位于任务根部的 activity 控制 window 大小。您的选择是:

  1. 回溯到您应用中所有可能的任务根 Activity,并确保它们都具有 android:resizeableActivity="false"

  2. 强制此 activity 进入另一个任务,通过 Intent 启动时的标志或清单设置

[更新] 在应用程序标签中设置 android:resizeableActivity="false"。现在可以使用了。

我以前遇到过这个问题,我试了很多次发现你必须的 添加 android:launchMode="singleTask" && android:resizeableActivity="false" 同时