How can I disable multiwindow mode for an Activity in Android N+

拈花ヽ惹草 提交于 2019-12-03 08:12:27

问题


In the developer preview for Android N, multi-window support is enabled by default. How can I disable it for activites? Also what will happen if a multi-window enabled app launches my disabled activity?


回答1:


In your manifest, you need:

android:resizeableActivity="false"

So in your manifest file, for each activity that you want to disable the feature in, it would be like:

<activity android:name=".SomeActivity"
    android:label="@string/app_name"
    android:resizeableActivity="false" />

Or, if you want to disable it in your entire app:

<application 
   android:resizeableActivity="false" >
    . . .
</application>

As for what will happen, Android just won't let your app go into multi-screen mode - it will just stay full screen. See https://developer.android.com/preview/features/multi-window.html and https://developer.android.com/guide/topics/manifest/activity-element.html#resizeableActivity.




回答2:


Note: While starting a Unresizable Activity You should also add Intent.FLAG_ACTIVITY_NEW_TASK flag to Intent.Otherwise it will inherit the properties from the root activity.

Add android:resizeableActivity="false" for your Activity in your Manifest file or you can also add this for your Application:

<activity android:name=".YourActivity"
android:label="@string/app_name"
android:resizeableActivity="false" />


来源:https://stackoverflow.com/questions/37311145/how-can-i-disable-multiwindow-mode-for-an-activity-in-android-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!