VLeonovs
VLeonovs

Reputation: 2251

Disable split screen android

Good Day,

I would like to disable split screen, and get the result what is shown in "Expected Result" screenshot. (Toast with text "App doesn't support split screen")

In the "Actual Result" screen you can see how android:resizeableActivity="false" affect on the app, but still split-screen enabled. How can I disable it at all ?

Actual Result:

enter image description here Expected Result:

enter image description here

Upvotes: 17

Views: 31841

Answers (4)

gcb
gcb

Reputation: 14548

Correct answer is Do not do it!

users will understand they got into a bad situation when they cannot scroll and will un-split... but if they have a tablet or big enough resolution, they will be able to use the split screen feature just fine! don't patronize users.

Then, if you really want to be obnoxious to users, the correct way to do this in a declarative, non-hacky, way with the android provided framework is:

Set your main activity to have android:launchMode="singleTop"

Doing other way may impact re-parenting, instance count, etc. This is the right way if you want to be a single application on top. While it works for bad layout choices, it is not recommended. Your accepted answer is screwing up how android stacks launcher activities (which impacts how memory is freed among other things). And the reason it doesn't work with resizeableActivity is because screen split isn't necessarily a resize... you can launch the application after splitting, so it is not a resize.

source https://developer.android.com/guide/topics/manifest/activity-element

Upvotes: 1

Anil Singhania
Anil Singhania

Reputation: 845

Add android:resizeableActivity="false" in application tag at manifest.xml file.

         <application
                android:name=".activity.MyApplication"
                android:allowBackup="true"
                android:icon="@drawable/btn_share_myapplication"
                android:label="@string/app_name"
                android:resizeableActivity="false"
                android:supportsRtl="true"
                android:theme="@style/AppTheme">
                <activity
                    android:name=".activity.SplashActivity"
                    android:screenOrientation="portrait">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>
        <activity... />
        </application>

Upvotes: 11

VLeonovs
VLeonovs

Reputation: 2251

What I found ?

We can't set android:resizeableActivity="false" in the <application> tag it is ignored. (mistake google documentation)

It works when I set it to the main activity

 <activity
        android:name=".activities.SplashScreenActivity"
        android:label="@string/app_name"
        android:theme="@style/splashScreenTheme"
        android:resizeableActivity="false">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    </activity>

Upvotes: 57

Rafal
Rafal

Reputation: 302

Try to set minHeight and miWidth as in example here:

<activity android:name=".MyActivity">
<layout android:defaultHeight="500dp"
      android:defaultWidth="600dp"
      android:gravity="top|end"
      android:minHeight="450dp"
      android:minWidth="300dp" />
</activity>

Taken from: https://developer.android.com/guide/topics/ui/multi-window.html

Upvotes: -4

Related Questions