Hi,
I am trying to display RewardedInterstitialAd with Xamarin.GooglePlayServices.Ads.Lite version 120.3.0.3
the problem that I have is that after ads has been displayed the window size is being changed .my guess is that there is something wrong with xamarin implementation and something that is annoying that Game1.window property is readonly ,the only thing that I can do to setting viewPort back to pervious state and calling graphic.ApplyChanges()
but it doesn’t have any effects and Game1.window still has wrong values.
my question is that how can I change this and where it is being set because I don’t see any place that you can set this
Thanks
Hi,
It’s because on android ClientSizeChanged and OrientationChanged don’t work properly since v3.6. See here for more details on my fix.
Hi,Thanks for your reply, I used your fix,I see some changes but still I have the problem, when Game running the Viewport is:
(X:0 Y:0 Width:1080 Height:1731)
however with official Monogame release it is :
(X:21 Y:0 Width:1080 Height:1731)
but after ad is being displayed and dismissed
then the viewport is:
(X:0 Y:0 Width:1080 Height:1794)
and even I set the viewport to correct value can call ApplyChanges() , it doesn’t have any effect ,it still have same values
What is the native resolution of the device?
Applychanges doesn’t get it’s value from the viewport but from the PrefferedBackBufferWidth/Height. Which you’d have to set to WindowBounds.
Can you catch the Window.ClientSizeChanged and see what are the values of
PrefferedBackBufferHeight and ClientBounds when the ad is dismissed?
Hi, the native resolution is 1080*1920
at the first time when game runs the PreferredBackBufferHeight is 1080 and ClientBounds is(0 0 1080 1731)
but when it is dismissed PreferredBackBufferHeight is 1080 and ClientBounds is (0 0 1080 1794)
well I could find a work around , in ClientSizeChanged instead of setting viewport . I calculate the game scale again with Matrix.CreateScale then everything seems normal again. however this behavior still remains strange to me and I can’t understand the reason. my other concerns is about this custom build .
will these fixes be a part of Monogame in next version?
Thanks
Does the Ad library changes something in the view, like hiding the info bar at the top or the keyboard?
Otherwise it seems like we are missing an event or there’s still a bug in calculating the view bounds correctly.
well actually to display Ad with Xamarin.GooglePlayServices.Ads.Lite, I am passing Game1.Activity to it so it can display ad, so maybe it change something.
the point is that both game and Ad are in full display mode.
I think I had a similar issue, though I’m not 100% sure if mine was the same as yours. Try this…
In your GameActivity.cs class (or whatever you called your main Android entry point), add the following code…
protected override void OnResume()
{
base.OnResume();
// When we resume (which also seems to happen on startup), hide the system UI to go to full screen mode.
HideSystemUI();
}
private void HideSystemUI()
{
// Apparently for Android OS Kitkat and higher, you can set a full screen mode. Why this isn't on by default, or some kind
// of simple switch, is beyond me.
// Got this from the following forum post: http://community.monogame.net/t/blocking-the-menu-bar-from-appearing/1021/2
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
View decorView = Window.DecorView;
var uiOptions = (int)decorView.SystemUiVisibility;
var newUiOptions = (int)uiOptions;
newUiOptions |= (int)SystemUiFlags.LowProfile;
newUiOptions |= (int)SystemUiFlags.Fullscreen;
newUiOptions |= (int)SystemUiFlags.HideNavigation;
newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;
decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
this.Immersive = true;
}
}