Search code examples
androidfullscreenxiaomi

How to detect full screen gesture mode in Mi devices programmatically


I am writing an Android application that needs to calculate the height of screen to display content correctly. But the height I got in Mi devices (Mi 9 SE) wasn't correct when switching to full screen gesture mode. How can I get the real height of the screen, or check if user turned on full screen gesture mode in Mi devices?

I have tried these suggestions.

  1. How to detect full screen gesture mode in android Q
  2. Android: detect navigation bar visibility
  3. Check for navigation bar

Solution

  • After searching and experimenting, I have found the only solution: How to detect full screen gesture mode in android Q.

    Instead of using ViewCompat.setOnApplyWindowInsetsListener() function, I just have to create a WindowInsets instance for the current context, then check the getSystemGestureInsets() for each edges. This is how I implemented to make a React Native's native module.

    If you need a listener to detect every changes, the solution above has done well on Android app. If you want this listener for React Native, you might want to find another approach, since I haven't made it work.