ANDROID N split screen settings

Source: Internet
Author: User

An overview
Android N released, the biggest highlight there are 2, native system to the application of split screen support and quick reply. Now only the split-screen feature, the latest Android N system support horizontal screen when the two app side-up, vertical screen when the top and bottom emissions, and on the Android TV, the native system also supports the app to achieve PIP. Users can also drag data between these two apps, such as dragging a file from an app's activity to another app's activity.
The user opens the split screen mode:
1 Click on the box in the lower right corner, go to Task Manager, press and hold the title bar of an app, drag it into the highlighted area of the screen, and the app gold enters the split-screen mode. Then select another app in the Task Manager and click it to make the app go into split-screen mode.
2 Open an app, then press and hold the block in the lower right corner, and the app that's already open will go into split screen mode. Then select another app in the Task Manager on the screen and click it to make the app go into split screen mode.
3 Latest found: drop-down notification bar, long press the settings icon in the upper right corner, will turn on the hidden Settings feature "System Interface Tuner", enter the settings interface, the bottom of the System Interface Tuner option, after entering select "other", "Enable split screen swipe gesture", you can swipe into the split screen mode from the Task Manager. When an app is already in full screen mode, swipe up from the small square in the lower right corner with your finger. This setting may change in the official version in the future, so don't rely too much on it.
The life cycle of the two-split screen mode
The first thing to note is that the split-screen mode does not change the activity's life cycle.
The official argument is that in Split-screen mode, the activity that the user has recently manipulated and activated will be considered topmost by the system. Other activity is in the paused state, even if it is a visible activity to the user. However, these visible activity in the paused state will receive a higher priority response than those that are not visible in the paused state. When the user is operating on an activity in a visible paused state, it will be restored to the resumed state and considered topmost by the system. And the activity that was in topmost will become paused state.
In Split-screen mode, an app can enter the paused state in a state that is visible to the user, which is different from the previous one. So your app should know when to actually pause when it's dealing with the business. For example, if a video player enters split-screen mode, video playback should not be paused in the onpaused () callback, but the video should be paused in the OnStop () callback and the video playback will resume in the OnStart () callback. With regard to how to know that you have entered split-screen mode, a void Onmultiwindowchanged (Boolean Inmultiwindow) callback has been added to the activity API of Android N, So we can know in this callback whether we have entered the split screen mode.
When the app enters split-screen mode, it will trigger activity's onconfigurationchanged (), which is the same as when we were in the process of switching from the screen to the other way, the difference is that here is the width/height are changed, and the screen switch is wide and high interchange. We'd better handle the change in runtime state, otherwise our app will be re-created, re-onCreate () again with the new wide-height size.
If the user resizes the window, the system will also trigger onconfigurationchanged () when necessary. If the app's dimensions are not fully drawn in the drag, the system will temporarily populate these areas with the Windowbackground property in the theme.
Three-set app split screen mode
If you fit into the Android n,android:resizeableactivity the default value is True, is the default support for split-screen. This property is set with the new property android:resizeableactivity= "True" under the <application> or <activity> tab in Androidmanifest.xml. After setting this property, your app/activity will be able to enter split-screen mode or free mode. If this property is set to False, then your app will not be able to enter the split screen mode, if you open the app, long press the small box in the lower right corner, the app will still be in full screen mode, the system will pop up toast prompt you can not enter the split screen mode.
Note: If you do not fit to Android N (Target < Android N), package app Compilesdkversion < Android N, your app can also support split screen!!!! The reason: If your app is not set to allow only activity vertical screen/horizontal screen, that is, no setting type android:screenorientation= "XXX" property, the device running Android n system or can be your app split screen!! But at this time the system does not guarantee the stability of the runtime, when entering the split-screen mode, the system will first pop up toast to prompt you to explain this risk.
Four Layout attributes
In Android N, we can add layout nodes to the manifest file and set some new added properties to set some behavior for split-screen mode, such as minimum size.
? android:defaultwidth
? android:defaultheight
? android:gravity
? android:minimalsize
We can add a layout child node to an Activity:

      <ActivityAndroid:name=". Mainactivity "Android:label= "@string/app_name"             >            <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>            <LayoutAndroid:defaultheight= "500DP"Android:defaultwidth= "600DP"android:gravity= "Top|end"                                />        </Activity>

Five support drag and drop
Now we can drag content between activity in two split-screen modes. In the Android N Preview SDK, view has added an API that supports dragging between activity. Specific classes and methods, you can refer to the N Preview SDK Reference, the main use of the following new interfaces:
? View.startdraganddrop (): View.startdrag () alternative, need to pass view.drag_flag_global to achieve cross-activity drag. If you need to pass URI permissions to the receiver activity, you can also set View.drag_flag_global_uri_read or view.drag_flag_global_uri_write as needed.
? View.canceldraganddrop (): Called by the initiator of the drag, cancels the current in-progress drag.
? View.updatedragshadow (): Called by the initiator of the drag-and-drop to set the shadow for the current drag-and-drop.
Android.view.DropPermissions: The list of permissions received by the receiving app.
? Activity.requestdroppermissions (): This method needs to be called when the URI permission is passed. The content that is passed is stored in the Clipdata in Dragevent. The return value is the previous android.view.DropPermissions.
Five test lists
For functional, performance-related testing, you can also follow the steps below.
To allow the app to enter, then exit split-screen mode to ensure that the app is functioning properly at this time.
? Let the app go into split screen mode, activate another app on the screen, and let your app enter the visible, paused state. For example, if your app is a video player, your app should not stop playing the video when the user taps another app on the screen, even if your activity/fragment has received a onpaused () callback.
To make the app go into split-screen mode, drag the small white line on the bar to change the app's size. Please change the size of the vertical screen (two apps on top of the layout) and the horizontal screen (two app one left and right layout) mode respectively. Make sure the app doesn't crash, that the features are working properly, and that the UI refresh doesn't take much time.
Change the app size in a short time, multiple times, and quickly to make sure the app doesn't crash and memory leaks are not happening. For more detailed memory usage considerations, refer to investigating Your RAM usage.
In the case of different Windows settings, use the app normally, make sure the app is working properly, the text is still readable, the other UI elements are not too small, and the user can still manipulate the app in a comfortable way.

ANDROID N split screen settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.