graphicsDevice.PresentationParameters has wrong backbuffer size on vanilla Android!

Hi There,

I’ve a game that has a few different Android configuration builds where one of it is in a vanilla form which basically doesn’t have any ad libraries, no internet connection and no googleplay integration. In this version, I observed that the backbuffer width and height is wrong on devices which has notch and virtual buttons. The same basic initilization code runs the same on all versions and is correct on all other version but not on that one. I use the same full screen procedure where I’ve a theme like this :

  <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:defaultFocusHighlightEnabled">false</item>
  </style>

And also use Window flags like this while the main acitivity is being created :

        //Make full screen
        if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.P)
        {
            Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
            Window.AddFlags(WindowManagerFlags.Fullscreen);
            Window.AddFlags(WindowManagerFlags.LayoutInOverscan);
        }

Anybody come across in such an issue before?

Regards,

Özden

It’s a bug feature in mg android.
Here is a previous reply on how you can fix it.

1 Like

Hey There,

Many thanks for pointing out this thread!

I believe I came across your custom build before but gave up to use my own custom build :slight_smile: which contains some other things for my needs for some reason. Anyway, I tried your build and it seems that it works a little bit better than the official one as now I can see my game in fullscreen but with a few issues. Since you are using “FullSensor” at start and than determine the screen orientation, some of my early initialization codes which calculates the bezel image locations doesn’t work properly, especially if I hold the device in portrait at launch. So what I would like to ask whether there is a way to launch the activity as “LandscapeSensor” as I already have in the GooglePlay/Non-Vanilla version?

Regards,

Özden Irmak
Creamative

You can’t do that. FullSensor is required to correctly detect the starting orientation.
In fact it will throw an exeption with a message to change it back.

You have to set the allowed orientation from within the Game class. That should work on all platforms that support orientation without changes in platform files.

See this sample back from xna/wp7 on how to do that.
you might also need to listen at orientation change event.

I understand and will adjust my code. There is one last thing I would like to ask, using your build, the navigationbar portion still seems to be not included, is there any other code that I should include for that? I tried to hide the navigationbar using Window.DecorView.SystemUiVisibility but that doesn’t seem to have any effect?

Thanks!

In terms of unexpected backbuffer sizes on Android (Google Play registered) titles, there is a fascinating phenomena detailed in this post that might also be worth considering:

https://community.monogame.net/t/android-screen-size-from-windowmanager-defaultdisplay-getrealsize-depends-on-package-name/

Hello Everyone,

I just wanted to update the situation and give a possible solution for future reference.

It seems that as soon as I added “google play services (games)” library into the game, everything started to work as it should. I did get the proper fullscreen and also the OS stopped complaining that my app is being built with an old version of Android and needs to be updated. So in short, even with on a vanilla project, it seems google play services (games) is more or less a must.

Regards,

Özden Irmak
Creamative

1 Like