Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] Launcher: Pixel 4 or newer, Android 12 forces split screen when opening files with default app #2023

Closed
NavaJoey opened this issue Jul 1, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@NavaJoey
Copy link

NavaJoey commented Jul 1, 2022

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

  1. Deploy your Xamarin App to a Pixel 4 or newer device
  2. 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
@NavaJoey NavaJoey added the bug Something isn't working label Jul 1, 2022
@Khadeeja-Madathil
Copy link

Also on Pixel 6.

@joemather
Copy link

Relates to #1817

@ivandamyanov
Copy link

ivandamyanov commented Jul 20, 2022

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.

@djrpascu
Copy link

djrpascu commented Sep 8, 2022

Does anyone have a workaround for this? Or do we build a local version of XE and apply changes @NavaJoey suggested ourselves?

@danpowell88
Copy link

danpowell88 commented Oct 13, 2022

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);
}

@BillyMartin1964
Copy link

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:

image

@kkppstudios
Copy link

kkppstudios commented Nov 15, 2022

I'm seeing this issue occur when simply doing a ComposeEmail() call too.

@andreasbrostencab
Copy link

Great that a fix seems on it's way.
When can I expect v 1.7.4 (with this fix included?) to be released?

@BillyMartin1964
Copy link

Thanks James and Gerald. You guys are great. Keep up the amazing work!

@rutgersc
Copy link

rutgersc commented Dec 8, 2022

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

@kkppstudios
Copy link

kkppstudios commented Dec 11, 2022

Still waiting for 1.7.4 on nuget.. @jfversluis
It's there now, thanks! 😁

@Cr15Denis
Copy link

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/

@Cr15Denis
Copy link

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:

WhatsApp.Video.2023-02-06.at.10.13.54.mp4

Solution:

In the Android project, in the file "MainActivity.cs"

solution

Result:

WhatsApp.Video.2023-02-06.at.10.17.45.mp4

I hope they can also solve the problem. greetings friends

@Cr15Denis
Copy link

Cr15Denis commented Feb 6, 2023 via email

@samuelGrahame
Copy link

samuelGrahame commented Feb 6, 2023 via email

jfversluis added a commit that referenced this issue Jan 26, 2024
* Added check for reduced accuracy

* Adjusted iOS version check to use Xamarin.Essentials DeviceInfo API

* Changed DeviceInfo API version check to Platform API version check

Co-authored-by: James Montemagno <[email protected]>

* Minor code fixes

* Update AppInfo.ios.tvos.watchos.macos.cs

* Update Xamarin.Essentials.csproj

* Bump AspNet.Security.OAuth.Apple to 3.1.8

Bump AspNet.Security.OAuth.Apple to 3.1.8 to resolve GHSA-3893-h8qg-6h5f.

* [BULK UPDATE] DocuTune - Rebranding links

* Update dependencies

* Enable CodeQL

* Update README.md

* Remove launch adjacent Fixes #2023

* Update App Center dependencies

* Update AndroidManifest.xml

* Update Xamarin.Essentials.csproj

* Update SecureStorage.android.cs

* Fix MediaPicker capture methods in Android 13+

Thanks to @Ghostbird in dotnet/maui#12766

* Update MediaPicker.android.cs

* Update MediaPicker.android.cs

* Update MediaPicker.android.cs

* error SA1027: Tabs and spaces should be used correctly

* Fix typos in MainThread.cs

Typo aysnc -> async

* Update FilePicker.xml

* Update azure-pipelines.yml

* Update README.md

* Update README.md

* fix share title on iOS

* Add compliance to buildpipline

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Fix

* Move files to right place

* Remove localization checks

* Remove gdn supression file

* Renamine devopsnuget.config to nuget.config

* Remove references to NuGet.config from cake

* Revert "Remove references to NuGet.config from cake"

This reverts commit 48fe60b.

* Revert "Renamine devopsnuget.config to nuget.config"

This reverts commit 953abd1.

* Add GDN suppress file

* Create NuGet.config

* dotnet tool restore first

* Revert "dotnet tool restore first"

This reverts commit 981b5d7.

* Use cake 2.1.0

* Hmm more cake

* Fix iOS Device Tests

* Revert "Fix iOS Device Tests"

This reverts commit 7db9187.

* Use Xcode 13.3

* Revert "Use Xcode 13.3"

This reverts commit 1138d28.

* Use macos-12 for iOS tests

* Revert "Revert "Use Xcode 13.3""

This reverts commit 7b5ab9c.

* Xcode 14.2

* Try fix iOS tests

* Update build.cake

* Update build.cake

* Bump xharness

* Updates for MonoAndroid13.0

* Update dependencies & obsoletes

* Set Windows JDK path

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update build.cake

* Remove devopsnuget.config

* Add Boots to DeviceTests

* Cake.Boots version upgrade

* async

* Update azure-pipelines.yml

* Update dependencies

* Xcode update

* EnableMultiDex DeviceTests

* Update azure-pipelines.yml

* Update DeviceTests.Android.csproj

* Update build.cake

* Update azure-pipelines.yml

* Update build.cake

* Revert "Update azure-pipelines.yml"

This reverts commit f826488.

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Fix Android Emulators

* More Android emulator fixes

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Clean up cake file

* Reenable API23 tests

* Revert "Reenable API23 tests"

This reverts commit 22a7e2f.

* Reenable API30 tests

* Add API33 tests

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update build.cake

* Update azure-pipelines.yml

* Add AndroidManifest entry for high sampling rate

* Disable API33 tests

* Disable API30 tests for now

* Fix failing auth redirect on Android

* Update CI version number

* Remove wrong Connectivity dispose calls on Android

* Make UWP FilePicker FutureAccessList more robust

* Add API34 compatibility for networking & battery

* Switch to Security v1 template for compliance (#2114)

* Update WebAuthenticator Sample app dependencies (#2116)

* Update WebAuthenticator Sample app to net8

* Revert "Update WebAuthenticator Sample app to net8"

This reverts commit 228ebdd.

* Update WebAuth Sample project dependencies

* Set APIScan version number

* Remove ms.prod = xamarin. Replaced by ms.service = xamarin (#2118)

Co-authored-by: Docs Allowlist Management <[email protected]>

* Remove ms.technology = xamarin-essentials paired with ms.prod = xamarin. Replaced by ms.subservice = xamarin-essentials paired with ms.service = xamarin (#2117)

Co-authored-by: Docs Allowlist Management <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>

---------

Co-authored-by: Leon Lucardie <[email protected]>
Co-authored-by: leonluc-dev <[email protected]>
Co-authored-by: James Montemagno <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
Co-authored-by: Martin Costello <[email protected]>
Co-authored-by: Alex Buck <[email protected]>
Co-authored-by: Jonathan Dick <[email protected]>
Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Ivo Snoza <[email protected]>
Co-authored-by: dimonovdd <[email protected]>
Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com>
Co-authored-by: Docs Allowlist Management <[email protected]>
jfversluis added a commit that referenced this issue Feb 26, 2024
* Added check for reduced accuracy

* Adjusted iOS version check to use Xamarin.Essentials DeviceInfo API

* Changed DeviceInfo API version check to Platform API version check

Co-authored-by: James Montemagno <[email protected]>

* Minor code fixes

* Update AppInfo.ios.tvos.watchos.macos.cs

* Update Xamarin.Essentials.csproj

* Bump AspNet.Security.OAuth.Apple to 3.1.8

Bump AspNet.Security.OAuth.Apple to 3.1.8 to resolve GHSA-3893-h8qg-6h5f.

* [BULK UPDATE] DocuTune - Rebranding links

* Update dependencies

* Enable CodeQL

* Update README.md

* Remove launch adjacent Fixes #2023

* Update App Center dependencies

* Update AndroidManifest.xml

* Update Xamarin.Essentials.csproj

* Update SecureStorage.android.cs

* Fix MediaPicker capture methods in Android 13+

Thanks to @Ghostbird in dotnet/maui#12766

* Update MediaPicker.android.cs

* Update MediaPicker.android.cs

* Update MediaPicker.android.cs

* error SA1027: Tabs and spaces should be used correctly

* Fix typos in MainThread.cs

Typo aysnc -> async

* Update FilePicker.xml

* Update azure-pipelines.yml

* Update README.md

* Update README.md

* fix share title on iOS

* Add compliance to buildpipline

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Fix

* Move files to right place

* Remove localization checks

* Remove gdn supression file

* Renamine devopsnuget.config to nuget.config

* Remove references to NuGet.config from cake

* Revert "Remove references to NuGet.config from cake"

This reverts commit 48fe60b.

* Revert "Renamine devopsnuget.config to nuget.config"

This reverts commit 953abd1.

* Add GDN suppress file

* Create NuGet.config

* dotnet tool restore first

* Revert "dotnet tool restore first"

This reverts commit 981b5d7.

* Use cake 2.1.0

* Hmm more cake

* Fix iOS Device Tests

* Revert "Fix iOS Device Tests"

This reverts commit 7db9187.

* Use Xcode 13.3

* Revert "Use Xcode 13.3"

This reverts commit 1138d28.

* Use macos-12 for iOS tests

* Revert "Revert "Use Xcode 13.3""

This reverts commit 7b5ab9c.

* Xcode 14.2

* Try fix iOS tests

* Update build.cake

* Update build.cake

* Bump xharness

* Updates for MonoAndroid13.0

* Update dependencies & obsoletes

* Set Windows JDK path

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update build.cake

* Remove devopsnuget.config

* Add Boots to DeviceTests

* Cake.Boots version upgrade

* async

* Update azure-pipelines.yml

* Update dependencies

* Xcode update

* EnableMultiDex DeviceTests

* Update azure-pipelines.yml

* Update DeviceTests.Android.csproj

* Update build.cake

* Update azure-pipelines.yml

* Update build.cake

* Revert "Update azure-pipelines.yml"

This reverts commit f826488.

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Fix Android Emulators

* More Android emulator fixes

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update build.cake

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Clean up cake file

* Reenable API23 tests

* Revert "Reenable API23 tests"

This reverts commit 22a7e2f.

* Reenable API30 tests

* Add API33 tests

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update build.cake

* Update azure-pipelines.yml

* Add AndroidManifest entry for high sampling rate

* Disable API33 tests

* Disable API30 tests for now

* Fix failing auth redirect on Android

* Update CI version number

* Remove wrong Connectivity dispose calls on Android

* Make UWP FilePicker FutureAccessList more robust

* Add API34 compatibility for networking & battery

* Switch to Security v1 template for compliance (#2114)

* Update WebAuthenticator Sample app dependencies (#2116)

* Update WebAuthenticator Sample app to net8

* Revert "Update WebAuthenticator Sample app to net8"

This reverts commit 228ebdd.

* Update WebAuth Sample project dependencies

* Set APIScan version number

* Remove ms.prod = xamarin. Replaced by ms.service = xamarin (#2118)

Co-authored-by: Docs Allowlist Management <[email protected]>

* Remove ms.technology = xamarin-essentials paired with ms.prod = xamarin. Replaced by ms.subservice = xamarin-essentials paired with ms.service = xamarin (#2117)

Co-authored-by: Docs Allowlist Management <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>

* Enable open source docs feedback (#2124)

* Enable open source docs feedback.

* Fix url.

* Fix repo link

---------

Co-authored-by: Leon Lucardie <[email protected]>
Co-authored-by: leonluc-dev <[email protected]>
Co-authored-by: James Montemagno <[email protected]>
Co-authored-by: Martin Costello <[email protected]>
Co-authored-by: Alex Buck <[email protected]>
Co-authored-by: Jonathan Dick <[email protected]>
Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Ivo Snoza <[email protected]>
Co-authored-by: dimonovdd <[email protected]>
Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com>
Co-authored-by: Docs Allowlist Management <[email protected]>
Co-authored-by: David Britch <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests