[Bug] Launcher: Pixel 4 or newer, Android 12 forces split screen when opening files with default app
Description
On Pixel 4 devices or newer with Android 12, if a file is opened using Launcher.OpenAsync() the file is opened in split screen mode adjacent to the source app regardless of whether android:resizeableActivity is false in the manifest file.
The issue is that when it goes into split screen mode the source app is reloaded and any in-progress state is lost in that app.
I've narrowed the problem down to the following logic in the PlatformOpenAsync() method of the Launcher.android.cs file:
#if __ANDROID_24__ if (Platform.HasApiLevelN) flags |= ActivityFlags.LaunchAdjacent; #endif
Removing this logic fixes the issue.
Steps to Reproduce
- Deploy your Xamarin App to a Pixel 4 or newer device
- Open a PDF or DOCX file from your Xamarin App using
Launcher
Expected Behavior
PDF or DOCX file should be opened in a new window and the source app state should remain as before if android:resizeableActivity is false
Actual Behavior
PDF or DOCX file is open adjacent in split screen mode and the source app is reloaded, losing any in-progress state
Basic Information
- Version with issue:
- Nuget Packages: Xamarin.Forms 5.0.0.2012, Xamarin.Essentials 1.7.1
- Affected Devices: Pixel 4a, Pixel 5
Also on Pixel 6.
Relates to https://github.com/xamarin/Essentials/issues/1817
A side effect of that is that deep linking was working fine but now my app crashes when it is opened. On Android 12, the system tries to go with the adjacent option and since that flag is in the intent, the app is always launched in multi window mode and since my app doesn't support that well, it now crashes. When I use StartActivity, without the Launcher, and I don't use the adjacent flag, it works fine.
Does anyone have a workaround for this? Or do we build a local version of XE and apply changes @NavaJoey suggested ourselves?
The following worked for me inside the MainApplication
public override void StartActivity(Intent intent)
{
// Hack to prevent split screen issues, needs to happen here
// as disabling in attributes causes app to crash
if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
intent.RemoveFlags(ActivityFlags.LaunchAdjacent);
base.StartActivity(intent);
}
I don't have a problem launching websites, but this happens when I try to use AppInfo.ShowSettingsUI(); and the above code doesn't help:

I'm seeing this issue occur when simply doing a ComposeEmail() call too.
Great that a fix seems on it's way. When can I expect v 1.7.4 (with this fix included?) to be released?
Thanks James and Gerald. You guys are great. Keep up the amazing work!
Thanks for the fix! Any idea when this will be available? I saw 1.7.4 on the github release page, but it's not yet available on nuget it seems. @jfversluis
Still waiting for 1.7.4 on nuget.. @jfversluis It's there now, thanks! 😁
hello friends I found this solution just apply "ResizeableActivity = false," in the MainActivity. https://devblogs.microsoft.com/xamarin/optimizing-android-apps-for-multi-window-mode/
I am attaching the problem I had on a Samsung galaxy A13 Android 12, And I am attaching the solution in Xamarin Forms Android.
Problem:
https://user-images.githubusercontent.com/70722700/217024937-e1b6e148-e6d0-43a5-a10c-a3bdb9e68901.mp4
Solution:
In the Android project, in the file "MainActivity.cs"

Result:
https://user-images.githubusercontent.com/70722700/217025670-ce964867-f603-4b5d-998c-1065494b27ea.mp4
I hope they can also solve the problem. greetings friends
Hello friend, right now I published the solution in the github ISSUE, take a look. greetings
De: Samuel @.> Enviado: domingo, 5 de febrero de 2023 20:52 Para: xamarin/Essentials @.> Cc: Cr15Denis @.>; Comment @.> Asunto: Re: [xamarin/Essentials] [Bug] Launcher: Pixel 4 or newer, Android 12 forces split screen when opening files with default app (Issue #2023)
hello friends I found this solution just apply "ResizeableActivity = false," in the MainActivity. https://devblogs.microsoft.com/xamarin/optimizing-android-apps-for-multi-window-mode/
I have this in my app:
Samsung galaxy note 20 - with the samsung app even without having launch LaunchAdjacent (forked copy) and removing the flag on start activity it still opens LaunchAdjacent.
does anyone have a workout around. (is this related to the edge panel in Samsung where you can specify to open in split view)
— Reply to this email directly, view it on GitHubhttps://github.com/xamarin/Essentials/issues/2023#issuecomment-1418261674, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQ3SJDHTIIEI7LTGSXHRSCDWWAHKTANCNFSM52LGVYWA. You are receiving this because you commented.Message ID: @.***>
Thank you, all solved.
On Tue, 7 Feb 2023, 3:22 am Cr15Denis, @.***> wrote:
I am attaching the problem I had on a Samsung galaxy A13 Android 12, And I am attaching the solution in Xamarin Forms Android.
Problem:
https://user-images.githubusercontent.com/70722700/217024937-e1b6e148-e6d0-43a5-a10c-a3bdb9e68901.mp4
Solution:
In the Android project, in the file "MainActivity.cs"
[image: solution] https://user-images.githubusercontent.com/70722700/217025138-c40a3109-e7c2-4408-ba58-5da877934642.png
Result:
https://user-images.githubusercontent.com/70722700/217025670-ce964867-f603-4b5d-998c-1065494b27ea.mp4
I hope they can also solve the problem. greetings friends
— Reply to this email directly, view it on GitHub https://github.com/xamarin/Essentials/issues/2023#issuecomment-1419357929, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGTV2ZJOVCVBZS2BMYXEJTWWEQLZANCNFSM52LGVYWA . You are receiving this because you commented.Message ID: @.***>