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

3

10

I want to disable multi-window support for an activity in my app. I have set resizeableActivity to false in my Manifest but when I long press recent app icon, the app still goes in multi-window mode. Below is my manifest:

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

Per 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.

I have also tried to set this attribute to false at application level in manifest but it still starts in multi-window mode. Any pointer on what I am doing wrong will be highly appreciated?

Ship answered 21/7, 2016 at 14:0 Comment(2)
This activity does not have an <intent-filter>. How is it being started? Is it being started by one of your other activities?Devaney
Hi, Yes its started internally by one of the other activity in the app. Thank you!Ship
D
7

The activity that is at the root of the task controls the window size. Your choices are:

  1. Trace back to all possible task root activities in your app and ensure they all also have android:resizeableActivity="false"

  2. Force this activity into another task, via Intent flags when you start it or manifest settings

Devaney answered 22/7, 2016 at 14:18 Comment(5)
Perfect...that fixed it. Thank you so much for your help!!! I had the flag set at application level but that did not work. When I set the flag at the root activity, that did the trick. Wondering why application level flag did not work? Thanks again!!Ship
@user899849: That attribute is only for <activity> and does not appear in the documentation for <application>.Devaney
It is worth saying that Intent.FLAG_ACTIVITY_NEW_TASK is notoriously buggy. So for others encountering this - you probably want to set the taskAffinity for the new activity to something different from the default. For example: <manifest ... <application ... <activity android:name="com.example.NoSplitActivity" android:screenOrientation="portrait" android:resizeableActivity="false" android:taskAffinity="com.example.NoSplitActivity" />Rivkarivkah
@Devaney - android:resizeableActivity=["true" | "false"] attribute is available at <application> level. Your fact is incorrect. I still don't understand what's the point of having an activity specific flag at application level? If mentioned at application level does it apply to all activities?Sixpence
@AKh: "android:resizeableActivity=["true" | "false"] attribute is available at <application> level" -- they added it to the docs sometime after I wrote that comment. "If mentioned at application level does it apply to all activities?" -- yes.Devaney
P
4

[UPDATE] set android:resizeableActivity="false" in application tag. This will work now.

Psalm answered 22/9, 2016 at 12:30 Comment(0)
D
0

I have meet this problem before, and I try many time find that your must add android:launchMode="singleTask" && android:resizeableActivity="false" at the same time.

Debonair answered 28/9, 2017 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.