I want to create an app for android nougat, when I click on a button I launch two apps at the same moment and the same screen. I want to use this new feature of Android 7, Is it possible?
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<AccessibilityWindowInfo> 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With