How do I open another app in a split screen in the android N (SDK 24)?
In the documentation I found this:
Launch New Activities in Multi-Window Mode
When you launch a new activity, you can hint to the system that the new activity should be displayed adjacent to the current one, if possible. To do this, use the flag Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT. Passing this flag requests the following behaviour:
If the device is in split-screen mode, the system attempts to create the new activity next to the activity that launched it, so the two activities share the screen. The system is not guaranteed to be able to do this, but it makes the activities adjacent if possible. If the device is not in split-screen mode, this flag has no effect. If a device is in freeform mode and you are launching a new activity, you can specify the new activity's dimensions and screen location by calling ActivityOptions.setLaunchBounds(). This method has no effect if the device is not in multi-window mode.
so when I tried this out, the Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT
flag does not exist. I installed
- Android 6.x (N) SDK 24 revision 1
- Android N Preview SDK N revision 3
- Android 6.0 (Marshmallow) SDK 23 revision 3
this is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "PACKAGENAME"
minSdkVersion 16
targetSdkVersion 24
versionCode 2
versionName "2.4.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
Hi Starting from android 7.0 you can go to Freeform multiwindow mode. Turn on developer options in your device and use following adb commands :
After you can use the following function to launch different activities in split screen programmatically: