Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically enter multi-window mode in Android N

Android N has a new feature - Multi Window Mode. It enables two applications to be active side-by-side (actually one one is active, other one is paused but we can see both simultaneously).

I am looking for an API that I can call to have my application enter multi-window mode. I couldn't find much help in Android N SDK docs. I am trying to have two activities of my app run side by side, but without user having to do manual steps.

MANUALLY ENTERING MUTLI-WINDOW MODE The user can switch into multi-window mode in the following ways:

If the user opens the Overview screen and performs a long press on an activity title, they can drag that activity to a highlighted portion of the screen to put the activity in multi-window mode. If the user performs a long press on the Overview button, the device puts the current activity in multi-window mode, and opens the Overview screen to let the user choose another activity to share the screen.

like image 764
Abhijit Ajmera Avatar asked Apr 12 '16 08:04

Abhijit Ajmera


People also ask

How do I open multiple windows in Android Studio?

Window -> Editor Tabs -> Split Vertically Show activity on this post. Show activity on this post. Show activity on this post. Show activity on this post.

How do I use Multi Window on Android 9?

On Android 9.0, with gesture controls enabled, you swipe up from the "pill" to the top of the screen. Tap the icon of the app you want on top of the split-screen. That will call up a menu from which you select "Split Screen." Lastly, you select the app you'd like at the bottom of the split-screen.


1 Answers

The SDK for API 24 introduced a new constant to toggle split screen mode from an accessibility service: https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html#GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN

The constant can be passed to following method: https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html#performGlobalAction(int)

Google seems to have missed to document the new constant in the performGlobalAction method. I still consider this to be an official API since Google did not mark the constant as hidden.

You have to implement an accessibility service in your app and let the user manually enable the service in system settings->Accessibility so it might not be a viable option for all apps.

like image 162
til77 Avatar answered Oct 19 '22 22:10

til77