Essentials
Essentials copied to clipboard
ShowSettingsUI() Split screen view
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
- Call the method: AppInfo.ShowSettingsUI();
- Show the result
Expected Behavior
The SettingsUI should appears in full-screen.
Actual Behavior
The SettingsUI appears in split screen view.
Screenshots
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?
[Activity(Label = "Name", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
Do I need to put an other attribute?
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);
}
I've seen it only on Samsung devices. Ex: Galaxy S20 Removing LaunchAdjacent fixes the problem
I'm having the same problem on Pixel devices (Pixel 6 and 7) running android 13.
This is fixed in the most recent versions!