Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

ShowSettingsUI() Split screen view

Open Abesoddy opened this issue 3 years ago • 5 comments

Description

Hello everyone,

I have an issue with my Xamarin Forms Application in Android, I tried to check and request camera permission. But if the result is Denied, I want to open Settings UI. To do that, I use this method: AppInfo.ShowSettingsUI();.

But when the SettingsUI appears, the screen is splitting. The settingsUI is opening on the top of the screen and the Xamarin Forms app is on the bottom. How can I keep the entire full screen when I open the settingsUI?

Steps to Reproduce

  1. Call the method: AppInfo.ShowSettingsUI();
  2. Show the result

Expected Behavior

The SettingsUI should appears in full-screen.

Actual Behavior

The SettingsUI appears in split screen view.

Screenshots

https://ibb.co/ZgGGj44

Abesoddy avatar Jun 21 '21 07:06 Abesoddy

Hmmm we use ActivityFlags.LaunchAdjacent; however I have never seen this split screen like this. What all do you set on your [Activity] attribute on the mainactivity that you are launching this from?

jamesmontemagno avatar Jun 21 '21 22:06 jamesmontemagno

[Activity(Label = "Name", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]

Abesoddy avatar Jun 22 '21 05:06 Abesoddy

Do I need to put an other attribute?

Abesoddy avatar Jun 29 '21 10:06 Abesoddy

I came across the same issue yesterday. I'm not familiar with multi-window devices, but the person who reported it as an error uses the affected device on a daily basis and got surprised to see the screen split, with the settings app above our running app.

It happens because of the LaunchAdjacent flag that James mentioned. Calling the intent like this from your Android app should work (this is the Xamarin Essentials implementation without the extra intent flag)

    static string PlatformGetPackageName() => Xamarin.Essentials.Platform.AppContext.PackageName;

    public void ShowSystemSettings()
    {
        var context = Xamarin.Essentials.Platform.CurrentActivity;

        var settingsIntent = new Intent();
        settingsIntent.SetAction(global::Android.Provider.Settings.ActionApplicationDetailsSettings);
        settingsIntent.AddCategory(Intent.CategoryDefault);
        settingsIntent.SetData(global::Android.Net.Uri.Parse("package:" + PlatformGetPackageName()));

        var flags = ActivityFlags.NewTask | ActivityFlags.NoHistory | ActivityFlags.ExcludeFromRecents;
        
        settingsIntent.SetFlags(flags);

        context.StartActivity(settingsIntent);
    }

mrjavicho avatar Jul 23 '21 10:07 mrjavicho

I've seen it only on Samsung devices. Ex: Galaxy S20 Removing LaunchAdjacent fixes the problem

brunonocetti avatar Apr 25 '22 16:04 brunonocetti

I'm having the same problem on Pixel devices (Pixel 6 and 7) running android 13.

wiebesteven avatar Nov 14 '22 08:11 wiebesteven

This is fixed in the most recent versions!

jfversluis avatar Dec 07 '23 14:12 jfversluis