Forum Xamarin.Forms

Double Status Bar on Android instance

Hello guys,

Recently I found a strange problem with one of my applications. I have a project written in Xamarin.Forms and it is available for iOS and Android. Few days ago I found a problem related to the Android's instance of the application and it's a strange kind of a problem. This bug is not reproducible on iOS but only on Android. When my application is running and I send it to the background (for example: pressing the home button of the phone) after I resume it from the phone's task manager it makes the top status bar double and it covers part of my UI. But if I resume it from the application's icon and not from the phone's task manager everything is O.K.

I couldn't find any solution to this strange problem.
Is there anyone facing the same problem? I'll be very grateful if someone can help me to resolve this.

Thank you in advance!

Regards.

Best Answer

  • KrisPetkovKrisPetkov BGMember ✭✭
    Accepted Answer

    @AlessandroCaliaro Unfortunately I don't have much time to create new project to test. But I found from where the problem was and also I found a workaround. It's not a solution but it does the job for now.

    The problem: After few hours of trying and digging different solution i decided to downgraded Xamarin.Forms package from Nuget Packages Manager. I downgraded my current version (the latest one 2.5.0.121934) 4-5 versions below and the problem disappeared. So it seems that it is a Xamarin bug. Something in their new versions. I assume that it is related with the iPhone X support because the black line is at the top of the screen and it seems that this bug appears sometime around releasing the version for iPhone X support. But this is just a guess.

    The workaround: In my portable project in the App class override the OnResume method. In this method put code like this:

    public override void OnResume() { MessagingCenter.Send(this, "simulateRotation"); }

    After this in the Droid project in MainActivity.cs file in OnCreate method put code like this:

    MessagingCenter.Subscribe<App>(this, "simulateRotation", sender => { RequestedOrientation = ScreenOrientation.Landscape; RequestedOrientation = ScreenOrientation.Portrait; });

    By this approach while the application resumes the code above will simulate phone rotation to landscape and immediately after this to portrait mode and the top black line will disappear. I found that when the black line is visible and you rotate the phone to landscape and back to portrait the line disappears. That's how I came up with this workaround for this problem.

    I hope that this solution will help someone else and we are going to wait for Xamarin team to fix this bug.

    Regards.

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    can you post a repo on github?

  • KrisPetkovKrisPetkov BGMember ✭✭
    @AlessandroCaliaro thank you for the response! Unfortunately I am not allowed to show any part of the source because the project is not personaly mine. I can show pictures of the problem. If you have something in mind you can ask me so I can check it in the source.
  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    you can create a new project that shows only the problem. I think it is not necessary to have all the project

  • KrisPetkovKrisPetkov BGMember ✭✭
    Accepted Answer

    @AlessandroCaliaro Unfortunately I don't have much time to create new project to test. But I found from where the problem was and also I found a workaround. It's not a solution but it does the job for now.

    The problem: After few hours of trying and digging different solution i decided to downgraded Xamarin.Forms package from Nuget Packages Manager. I downgraded my current version (the latest one 2.5.0.121934) 4-5 versions below and the problem disappeared. So it seems that it is a Xamarin bug. Something in their new versions. I assume that it is related with the iPhone X support because the black line is at the top of the screen and it seems that this bug appears sometime around releasing the version for iPhone X support. But this is just a guess.

    The workaround: In my portable project in the App class override the OnResume method. In this method put code like this:

    public override void OnResume() { MessagingCenter.Send(this, "simulateRotation"); }

    After this in the Droid project in MainActivity.cs file in OnCreate method put code like this:

    MessagingCenter.Subscribe<App>(this, "simulateRotation", sender => { RequestedOrientation = ScreenOrientation.Landscape; RequestedOrientation = ScreenOrientation.Portrait; });

    By this approach while the application resumes the code above will simulate phone rotation to landscape and immediately after this to portrait mode and the top black line will disappear. I found that when the black line is visible and you rotate the phone to landscape and back to portrait the line disappears. That's how I came up with this workaround for this problem.

    I hope that this solution will help someone else and we are going to wait for Xamarin team to fix this bug.

    Regards.

Sign In or Register to comment.