4

In Android, I have developed two Apps. I want to launch both apps in split screen mode programmatically with one launcher. How do I do that?

M. Usman Khan
  • 3,689
  • 1
  • 59
  • 69

2 Answers2

1

I found the answer.

You can use Accessibility API for such feature. It doesn't require any permissions.

android.accessibilityservice.AccessibilityService has following apis:

service.performGlobalAction(GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN) which you can use to initiate split screen mode.

public List getWindows () to check wether split screen mode is on. Look for a window with AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER

You also will need to play with intent flags when launching activities.

 val options = ActivityOptionsCompat.makeBasic().toBundle()?.apply {
     putInt(
         ActivityOptionsFlags.KEY_LAUNCH_WINDOWING_MODE,
         ActivityOptionsFlags.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
     )
     putInt(
         ActivityOptionsFlags.KEY_SPLIT_SCREEN_CREATE_MODE,
         ActivityOptionsFlags.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT
     )
 }

 startActivities(listOf(intentBottom, intentTop).toTypedArray(), options)

Using this accessibility apis and intent flags you can achieve your goal. Consult this repo by stavangr for detailed implementation.

https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html

M. Usman Khan
  • 3,689
  • 1
  • 59
  • 69
0

I did search about this long time back but never found any content to launch multiple application using single launcher.Best case i got is in my Samsung device(after s8 series) which support's application pairing(manual by user doc)

What i believe is that Samsung are allowing it as they must have supported it for there custom Android OS.Just like they have there own custom context Menu code and many other tweaks.

Reference gif

Anmol
  • 8,110
  • 9
  • 38
  • 63