How to disable the SplitScreen mode in Android 7.1.1 without disabling the MultiWindow mode?
I am using Freeform Window Mode to open multiple activities. In landscape orientation of device when an activitiy is dragged to the left or right edge of the screen the activity gets docked and the StackDivider splits the screen. Disabling MultiWindow mode eventually disables Freeform Window mode. So is there any way to disable the SplitScreen mode only (without disabling MultiWindow mode) by editing the Android source code?
https://developer.android.com/guide/topics/ui/multi-window.html
As per documentation, do this in you manifest activity or application
android:resizeableActivity=["true" | "false"]
In freeform mode, when an application or window is moved left or right corner of the screen by dragging its DecorCaptionView a dim layer is generated either at left or right depending on the position of window and it get docked to the current dim side on MOtionEvent.ACTION_UP event.
The MotionEvent actions on DecorCaptionView is handled by frameworks/base/services/core/java/com/android/server/wm/TaskPositioner.java and moveTaskToDockedStack() method in ActivityManagerService is invoked whenever a window gets docked. The updateDimLayerVisibility() method in TaskPositioner.java is responsible for the creation of dim layer. So the SplitScreen mode can be disabled by commenting out above mentioned two method calling lines in TaskPositioner.java.
Related
I'm setting my screen to be always awake in order to preventing it from going into sleep mode at all.
hence, when the screen display is turned off, the user has to touch the screen in order to bring it on again, but the problem is that this touch is received by the foreground activity and it reacts according to it, and the user is for sure just trying to turn the screen display on.
I tried to set the following flags but didn't work:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
&&
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
To resolve your issue you have to do one of the below things which prevents screen to turn off automatically.
Add android:keepScreenOn="true" to some widget in your layout XML resource for this activity. So long as that widget is visible on the screen, the screen will not turn off automatically.
OR
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to disable the screen timeout and
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to re-enable it.
I created sample project using Android Studio: Create new Project -> Navigation Drawer Activity. In testing purposes, my content Fragmentcontains just a single EditText widget.
In my AndroidManifest I have this line for the main activity:
android:windowSoftInputMode="stateUnchanged|adjustResize"
Odd behavior: if I launch the app in portrait mode, open soft keyboard (by tapping on the EditText) and rotate device to landscape mode... keyboard disappears for some reason. If I create the same project but with no NavigationDrawer (just Activity + Fragment) the keyboard remains visible (as expected with stateUnchanged property).
Did anyone know what is the reason of such behavior? Actually I want to keep the keyboard expanded after switching to landscape mode (if it was opened in portrait). I can track keyboard state and via special flag restore its visibility when needed programmatically, I know. I just wonder why the native tools don't work with NavigationDrawer.
In the new KitKat there is immersive full screen mode that can be used like this:
To provide your app with a layout that fills the entire screen, the
new SYSTEM_UI_FLAG_IMMERSIVE flag for setSystemUiVisibility() (when
combined with SYSTEM_UI_FLAG_HIDE_NAVIGATION) enables a new immersive
full-screen mode.
http://developer.android.com/about/versions/android-4.4.html#UI
I'm wondering if it is possible to set this mode for an Activity or full application in the manifest?
There is no way to declare immersive mode in the manifest or window flags.
It's only available via the view-level SYSTEM_UI_FLAG_IMMERSIVE flags, which indicates that it is a request, not a mandate - and that it is a temporary mode.
The system may choose to ignore the request or exit immersive mode at any time, your app should handle those cases.
It's also worth pointing out that hiding the primary navigation on a mobile device is not something to be taken lightly. It's not appropriate for all apps, and should not be done without thought.
a while back I converted my app to include landscape mode, from each activity having screenOrientation="portrait" to this:
<activity
android:name="bundle.android.views.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="fullSensor">
I also handle configuration changes just fine in onConfigurationChanged in each activity.
But in hindsight, I only want edge cases with pop out hardware keyboards to get landscape mode. How do I adjust my manifest and code?
do I keep a certain combination android:configChanges ? the onConfigurationChanged class? insight appreciated
One option is to tackle this problem programmatically. What you could do is detect if the user has a hardware keyboard attached, and if so force the orientation into landscape mode. Here are two ways to detect a hardware keyboard:
http://developer.android.com/reference/android/content/res/Configuration.html#keyboard
and
if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
}
Once you have detected that the user has a hard keyboard you can force landscape mode on the user with:
myActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
I implement my application which uses multi window feature. What I want is to know, can I catch the entering to the multi window mode? Are there any listeners for it?
I don't think there is currently a listener for multi-window mode.
What I would try to do is to add a Callback to the window, and detect when the window size is changed (through onWindowAttributesChanged).