So, TouchScreenKeyboard.area returns zero rect, anyone has a solution or plugin? Seems like an old issue.
Ok, so this is what I got so far, works atm and it's enought for now: Code (CSharp): using(AndroidJavaClass UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView"); using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect")) { View.Call("getWindowVisibleDisplayFrame", Rct); return Screen.height - Rct.Call<int>("height"); } }
Code (CSharp): public int GetKeyboardSize() { using (AndroidJavaClass UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView"); using (AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect")) { View.Call("getWindowVisibleDisplayFrame", Rct); return Screen.height - Rct.Call<int>("height"); } } }
The Code above is very helpful, but it returns only the height of keyboard, so if there an input field it will be ignored. Have someone an idea how to get the size of the additional input field?
In complement to this solution, which work fine on Android. Has anyone found a similiar solution for iOS devices ?
calling this function when the keyboard is visible but still getting 0 as a result. Has anyone experienced this?
This code is all over the internet, but the returned value doesn't include the height of the text input box. Has anyone figured out how to solve that one? (without just adding a hacky constant to make it almost-work?)
Code (CSharp): public static float GetKeyboardHeightRatio() { if (Application.isEditor) return 0.4f; #if UNITY_ANDROID using (var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { var view = unityClass.GetStatic<AndroidJavaObject>("currentActivity") .Get<AndroidJavaObject>("mUnityPlayer") .Call<AndroidJavaObject>("getView"); var dialog = unityClass.GetStatic<AndroidJavaObject>("currentActivity") .Get<AndroidJavaObject>("mUnityPlayer") .Get<AndroidJavaObject>("b"); var decorView = dialog.Call<AndroidJavaObject>("getWindow") .Call<AndroidJavaObject>("getDecorView"); var height = decorView.Call<int>("getHeight"); using (var rect = new AndroidJavaObject("android.graphics.Rect")) { view.Call("getWindowVisibleDisplayFrame", rect); return (float) (Screen.height - rect.Call<int>("height") + height) / Screen.height; } } #elif UNITY_IOS return (float) TouchScreenKeyboard.area.height / Screen.height; #endif } I get dialog with EditText (in Unity 2018.2.x this is a field "b") and take the height of this dialog. This code may not work in newer versions of Unity.
I can confirm this still works as of Unity 2019.1.4. If someday it ceases to work (assuming they don't change the android player considerably), to get the name of the field you need to access instead of "b", decompile Unity's android player jar file, and look inside the showSoftInput method. It'll look like this: Code (CSharp): protected void showSoftInput(final String string2, final int n2, final boolean bl, final boolean bl2, final boolean bl3, final boolean bl4, final String string3, final int n3, final boolean bl5) { this.a(new Runnable(){ @Override public final void run() { UnityPlayer.this.b = new k(UnityPlayer.this.r, this, string2, n2, bl, bl2, bl3, string3, n3, bl5); UnityPlayer.this.b.show(); } }); } You want whichever field is instantiated and accessed here. Unity devs: can't you at least exclude that field from obfuscation? XD
Hi In Unity 2019.1.5 I have a null reference in this line Code (CSharp): var decorView = dialog.Call<AndroidJavaObject>("getWindow") .Call<AndroidJavaObject>("getDecorView"); Edit: dialog is null
With some help from a script on GitHub and this thread here is our solution that allows you to get the height including the native keyboards input area. We had trouble with other solutions because they didn't consider the input area and because we're using Resolution Scaling Mode -> Fixed DPI which means Screen.height returns the height Unity is rendering in rather than the pixel height of the device's display which was messing up the calculations. This is the script from GitHub - https://github.com/kabirules/ANP/bl.../Scripts/Internal/Utils/AndroidDialogUtils.cs Our solution - Code (CSharp): using UnityEngine; public static class MobileUtilities { /// <summary> /// Returns the keyboard height ratio. /// </summary> public static float GetKeyboardHeightRatio(bool includeInput) { return Mathf.Clamp01((float) GetKeyboardHeight(includeInput) / Display.main.systemHeight); } /// <summary> /// Returns the keyboard height in display pixels. /// </summary> public static int GetKeyboardHeight(bool includeInput) { #if UNITY_ANDROID using (var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { var unityPlayer = unityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer"); var view = unityPlayer.Call<AndroidJavaObject>("getView"); var dialog = unityPlayer.Get<AndroidJavaObject>("mSoftInputDialog"); if (view == null || dialog == null) return 0; var decorHeight = 0; if (includeInput) { var decorView = dialog.Call<AndroidJavaObject>("getWindow").Call<AndroidJavaObject>("getDecorView"); if (decorView != null) decorHeight = decorView.Call<int>("getHeight"); } using (var rect = new AndroidJavaObject("android.graphics.Rect")) { view.Call("getWindowVisibleDisplayFrame", rect); return Display.main.systemHeight - rect.Call<int>("height") + decorHeight; } } #else var height = Mathf.RoundToInt(TouchScreenKeyboard.area.height); return height >= Display.main.systemHeight ? 0 : height; #endif } } EDIT: Fixed this to work in 2019.3
What makes you think it doesn't work on iOS? Did you try it? It's working on iOS for us. Your question is very vague. What exactly do you want to do?
This stopped working for us when upgrading to 2019.3. I decompiled the jar and it looks like this field is now called "mSoftInputDialog" instead of "b" Code (CSharp): protected void showSoftInput(final String s, final int n, final boolean b, final boolean b2, final boolean b3, final boolean b4, final String s2, final int n2, final boolean b5) { this.runOnUiThread(new Runnable() { @Override public final void run() { (UnityPlayer.this.mSoftInputDialog = new k(UnityPlayer.this.mContext, UnityPlayer.this, s, n, b, b2, b3, s2, n2, b5)).show(); UnityPlayer.this.nativeReportKeyboardConfigChanged(); } }); } Sadly changing this didn't fix it ...Get<AndroidJavaObject>("mSoftInputDialog") still fails to find something. Has anybody else had some luck getting the height of an Android keyboard (without the input line) in 2019.3 ?
It's strange. All works fine when I use 'mSoftInputDialog' instead of 'b'. Here is my code. Also, don't forget that this method returns a non-zero value after the keyboard finished appearing animation. Code (CSharp): public static int GetKeyboardHeight(bool includeInput) { #if UNITY_ANDROID using (var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { var unityPlayer = unityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer"); var view = unityPlayer.Call<AndroidJavaObject>("getView"); var result = 0; if (view != null) { using (var rect = new AndroidJavaObject("android.graphics.Rect")) { view.Call("getWindowVisibleDisplayFrame", rect); result = Display.main.systemHeight - rect.Call<int>("height"); } if (includeInput) { var dialog = unityPlayer.Get<AndroidJavaObject>("mSoftInputDialog"); var decorView = dialog?.Call<AndroidJavaObject>("getWindow").Call<AndroidJavaObject>("getDecorView"); if (decorView != null) { var decorHeight = decorView.Call<int>("getHeight"); result += decorHeight; } } } return result; } #else var height = Mathf.RoundToInt(TouchScreenKeyboard.area.height); return height >= Display.main.systemHeight ? 0 : height; #endif }
I want to scroll/resize my scrollview object when keyboard is on screen. So I tried using this, and it gives me height of soft keyboard In some device it returns proper and my scrollview is resized properly but in some device but in some device it isn't working fine. Any suggestions? Is it returning proper height in all different sized android devices?
I got this to work relative to the canvas size, here is the code... All you need is to call it with the canvas RectTransform reference. Code (CSharp): public static int GetRelativeKeyboardHeight(RectTransform rectTransform, bool includeInput) { int keyboardHeight = GetKeyboardHeight(includeInput); float screenToRectRatio = Screen.height / rectTransform.rect.height; float keyboardHeightRelativeToRect = keyboardHeight / screenToRectRatio; return (int) keyboardHeightRelativeToRect; } private static int GetKeyboardHeight(bool includeInput) { #if UNITY_EDITOR return 0; #elif UNITY_ANDROID using (AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { AndroidJavaObject unityPlayer = unityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer"); AndroidJavaObject view = unityPlayer.Call<AndroidJavaObject>("getView"); AndroidJavaObject dialog = unityPlayer.Get<AndroidJavaObject>("mSoftInputDialog"); if (view == null || dialog == null) return 0; var decorHeight = 0; if (includeInput) { AndroidJavaObject decorView = dialog.Call<AndroidJavaObject>("getWindow").Call<AndroidJavaObject>("getDecorView"); if (decorView != null) decorHeight = decorView.Call<int>("getHeight"); } using (AndroidJavaObject rect = new AndroidJavaObject("android.graphics.Rect")) { view.Call("getWindowVisibleDisplayFrame", rect); return Screen.height - rect.Call<int>("height") + decorHeight; } } #elif UNITY_IOS return (int)TouchScreenKeyboard.area.height; #endif }
Solved an issue I had where the keyboard height was returning the wrong values on other screen resolutions. Thanks so much
due to my dependency on this thread and the others like it in this forum for getting something working, i decided i'd offer my current workaround solution. after a number of failed tests over a day-and-a-half, where the code above would only work the first time i called it, and return zero (0) thereafter, i ended up making changes to GetKeyboardHeight() to make it more consistent in its output. the primary reason was that the original code failed to address the numerous timing issues i've found in using AndroidJava classes within Unity (written a few native Android apps; been using Unity for 24 months or so). in this case, because TouchScreenKeyboard.visible lies about the keyboard being completely visible when 'true', it's necessary to write the code that touches Android with this in mind. the code: Code (CSharp): // some Android-specific constants (some have changed over time) private const string _playerClass = "com.unity3d.player.UnityPlayer"; private const string _playerActivity = "currentActivity"; private const string _playerObject = "mUnityPlayer"; private const string _keyboardDialog = "mSoftInputDialog"; private const string _keyboardRect = "android.graphics.Rect"; private static int GetKeyboardHeight(bool includeInputField) { using (AndroidJavaObject unityActivity = new AndroidJavaClass(_playerClass).GetStatic<AndroidJavaObject>(_playerActivity)) { AndroidJavaObject unityPlayer = unityActivity.Get<AndroidJavaObject>(_playerObject); AndroidJavaObject view = unityPlayer.Call<AndroidJavaObject>("getView"); if (view == null) { return 0; } AndroidJavaObject dialog = unityPlayer.Get<AndroidJavaObject>(_keyboardDialog); while (dialog == null) { dialog = unityPlayer.Get<AndroidJavaObject>(_keyboardDialog); } int decorHeight = 0; if (includeInputField) { AndroidJavaObject decorView = dialog.Call<AndroidJavaObject>("getWindow").Call<AndroidJavaObject>("getDecorView"); while (decorView == null) { decorView = dialog.Call<AndroidJavaObject>("getWindow").Call<AndroidJavaObject>("getDecorView"); } decorHeight = decorView.Call<int>("getHeight"); while (decorHeight == 0) { decorHeight = decorView.Call<int>("getHeight"); } // Debug.Log("decorHeight ==> [ " + decorHeight + " ] "); } using (AndroidJavaObject rect = new AndroidJavaObject(_keyboardRect)) { view.Call("getWindowVisibleDisplayFrame", rect); int frameHeight = rect.Call<int>("height"); // Debug.Log("frameHeight ==> [ " + frameHeight + " ] "); int returnVal = Screen.height - frameHeight + decorHeight; // Debug.Log("returnVal ==> [ " + returnVal + " ] "); return returnVal; } } mostly, this code just waits until dependent variables are either not 'NULL' or non-zero. i left in the debug, 'cause that's the way it appears in my code. FYI, i didn't just alter GetKeyboardHeight(). i made other changes for the sake of robustness and removing ambiguity for Android. i haven't seen this info elsewhere, and your mileage may vary. i added : Code (CSharp): android:windowSoftInputMode="stateUnspecified|adjustNothing" to my AndroidManifest.xml file to make sure that the OS didn't help me while my code was making adjustments. if you're unsure where to add that line check here : https://developer.android.com/guide/topics/manifest/activity-element i added : Code (CSharp): inputField.shouldHideMobileInput = false; to each InputField instance that was going to be subject to my adjustments. i didn't depend solely on : Code (CSharp): TouchScreenKeyboard.visible to determine when to make the call to GetRelativeKeyboardHeight(). i also added a dependency on : Code (CSharp): inputField.touchScreenKeyboard.status == TouchScreenKeyboard.Status.Visible last thing, i waited until the last possible minute to make the call to GetRelativeKeyboardHeight(), so that i could be reasonably certain the keyboard would be visible. it was the last call i made after ensuring that TouchScreenKeyboard.visible and touchScreenKeyboard.status indicated keyboard visibility. context : Unity 2019.4.17f1 on OS X, tested on a Pixel XL running Android 8.1.0 (Oreo) ...END-OF-LINE...
Best solution I found is to use this, works on Android and IOS, but if you have set Fixed DPI in player settings - Resolution for Android/IOS it breaks it, I found https://github.com/baba-s/UniSoftwareKeyboardArea
sorry to hear that. still working fine for me (now on Unity 2019.4.19f1), but as i said, your mileage may vary. glad you found another workaround.
Yeah my main issue was it doesn't work when using Fixed DPI set in player settings - Resolution ~ which I was using for app performance reasons, however I found some workarounds to not need fixed DPI set for my app. Just wanted to post to let other users know if they try to read onscreen keyboard height while using Fixed DPI, the results are inconsistent and on android I had crashes, turning off Fixed DPI fixed it for me
I've been using the code in this thread for Android and have been getting weird results. I'm using Unity 2020.3.6 and a Google Pixel 2 with Android 11. The phone has a screen height of 1920. My problem is the rect's height from getWindowVisibleDisplayFrame returns 1794 saying the keyboard is only 126 tall. The keyboard covers at least 40% of the screen so these numbers are way off. The only reason I think this could happen is I'm using AR in the same scene which could be altering the resolution so it may be a similar problem to ROBYER1 but I don't have Fixed DPI enabled. If anyone has any insight or help It would be much appreciated, thanks.
I also had inconsistent results on android, we ended up using the Asset store asset Advanced Input field 2 which has its own Keyboard height callback and even a simulated input field in the editor. I would advise to use that asset and also use this fix so the caret doesn't break while in AR (a bug I reported too) https://github.com/support-fennecx/advancedinputfield2/issues/35#issuecomment-830827577
This work for me but not perfect. I have to wait 1.5 seconds (for the keyboard showing animation finish), to get it's height exactly. But in some cases, 1.5s is not enough. Anyone know how to handle the keyboard animation finish event?
Thank you for posting this, it looks like I am getting the right values if I wait for a second or two. I had a similar experience with getting WebCamTexture size. For that I kept checking the size until it was above a certain value. I don't think there is an event for keyboard animation finish, I think I will keep checking the value in a while the keyboard is open and update my screen if the value changes.
We are trying to get keyboard height in android device. we have tried the above solutions, but we are not getting exact keyboard height. In some of the android devices we are getting 0 height. We also want the height of includeInput (inputfield), and for this we tried the solution of decorHeight but that is also not working. unity version 2020.3.11 Android Api level- 24 and above Can you/anyone please help on this.
sorry that you're not having success with the code fragment. as i said, your mileage may vary. i'm currently running it successfully with no changes (last i checked) on Unity 2020.3.22f1 on OS X, tested on both a Pixel XL running Android 8.1.0 (Oreo) and a Samsung Galaxy S8+ running Android 9 (Pie). while i can't suggest a fix without knowing specifically what you're doing or how you've coded everything up, i can offer that the main point of the code fragment is to try to wait in while-loops for the various components of the Android keyboard to become visible to the Unity code. if you're not getting some kind of height value, you're probably not waiting long enough. it's also important to wait to call GetKeyboardHeight() until the last possible moment in your Update() loop. for me this meant not calling that function until: the input field had focus, AND the inputField.touchScreenKeyboard.status was equal to TouchScreenKeyboard.Status.Visible. in my code, i have a couple of variable assignments and a one-line mathematical calculation between 1 & 2. together, that may affect the timing a little, but i don't think this is germane here. this is mostly all i can tell you. one last thought: having tried the code above on multiple phones now, with varying levels of success, i think the next time i'll try to attack this problem, i'll completely remove any dependency on Unity code and just write the code in Android-Java as a plugin. i essence, i'll be creating my own event from Java to tell Unity that the keyboard is visible and that it has a height of 'X'. this way, i'll be talking directly with the platform and can confirm at that level that the keyboard is visible, and measure then the height thereafter. not sure when i'll get around to that. good luck!...END-OF-LINE...
There is a weird issue that TouchScreenKeyboard.area.height returns device height instead of keyboard height. Tested on Iphone 6s. Unity 2021.3.3f1 Silicon. I double checked but keyboard height always returns device height of Iphone 6s which is 1334px. What can possible reason of that?
so, i have this now on my list of stuff to do sometime in the next couple of our sprints. presuming it works, that other people still need it, and someone else hasn't already solved it by then, i'll share what i have. again, ymmv, but it'll be an option. ...END-OF-LINE...
assuming something else doesn't get in the way (and it might), i should start on this next week. no idea how long it will take or how portable it will be, but it will be a plugin intended to create "my own event from Java to tell Unity that the keyboard is visible and that it has a height of 'X'." when i have it working, i'll post code here or github or somewhere.
When using the provided code above, if you can retrieve a value but it is incorrect, it may be due to this reason. Open the AndroidManifest file in your project and check if the Activity tag has the "android:windowSoftInputMode" attribute. Its value should be "adjustResize" or "adjustPan". If its value is "adjustNothing," it is highly likely that this issue is causing the incorrect value return.
We were using the following code for some time, which was based I think on one of the suggestions in this thread: Code (CSharp): var view = currentActivity .Get<AndroidJavaObject>( "mUnityPlayer" ) .Call<AndroidJavaObject>( "getView" ) ; using ( var rect = new AndroidJavaObject( "android.graphics.Rect" ) ) { view.Call( "getWindowVisibleDisplayFrame", rect ); return Screen.height - rect.Call<int>( "height" ); } However we recently noticed a crash, which we tracked down to this code; basically, it is leaking references and because we were calling it every frame on a particular screen, it would eventually overflow some table of references leading to a crash. We fixed it by adjusting the code as follows: Code (CSharp): using (var mUnityPlayer = currentActivity.Get<AndroidJavaObject>( "mUnityPlayer" )) { using (var view = mUnityPlayer.Call<AndroidJavaObject>( "getView" )) { using ( var rect = new AndroidJavaObject( "android.graphics.Rect" ) ) { view.Call( "getWindowVisibleDisplayFrame", rect ); return Screen.height - rect.Call<int>( "height" ); } } } The crash details in case it helps someone find this issue: 12-20 16:06:49.230 27891 27974 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 27974 (UnityMain), pid 27891 (and.xxx.xxx) 12-20 16:06:49.763 4440 4440 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 12-20 16:06:49.763 4440 4440 F DEBUG : Build fingerprint: 'Nothing/PongEEA/Pong:13/TKQ1.221220.001/2310242214:user/release-keys' 12-20 16:06:49.763 4440 4440 F DEBUG : Revision: '0' 12-20 16:06:49.763 4440 4440 F DEBUG : ABI: 'arm' 12-20 16:06:49.764 4440 4440 F DEBUG : Timestamp: 2023-12-20 16:06:49.369337539+0100 12-20 16:06:49.764 4440 4440 F DEBUG : Process uptime: 3352s 12-20 16:06:49.764 4440 4440 F DEBUG : Cmdline: xxx.xxx 12-20 16:06:49.764 4440 4440 F DEBUG : pid: 27891, tid: 27974, name: UnityMain >>> xxx.xxx <<< 12-20 16:06:49.764 4440 4440 F DEBUG : uid: 10376 12-20 16:06:49.764 4440 4440 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- Abort message: 'JNI ERROR (app bug): global reference table overflow (max=51200)global reference table dump: Last 10 entries (of 51200): 51199: 0x70fea5a0 java.lang.Class<android.graphics.Rect> 51198: 0x13fdbcf8 java.lang.Class<com.unity3d.player.UnityPlayer> 51197: 0x13fdb9b8 com.unity3d.player.UnityPlayer 51196: 0x13fd73c0 android.view.MotionEvent 51195: 0x13fdb9b8 com.unity3d.player.UnityPlayer 51194: 0x13fdbcf8 java.lang.Class<com.unity3d.player.UnityPlayer> 51193: 0x13fdbcf8 java.lang.Class<com.unity3d.player.UnityPlayer> 51192: 0x13fdb9b8 com.unity3d.player.UnityPlayer 51191: 0x13fdbcf8 java.lang.Class<com.unity3d.player.UnityPlayer> 51190: 0x13fdb9b8 com.unity3d.player.UnityPlayer 12-20 16:06:49.764 4440 4440 F DEBUG : Summary: 12-20 16:06:49.764 4440 4440 F DEBUG : 25778 of java.lang.Class (395 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 25167 of com.unity3d.player.UnityPlayer (1 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 23 of java.lang.String (22 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 21 of java.util.ArrayList (21 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 19 of com.android.billingclient.api.BillingResult (3 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 18 of java.lang.ref.WeakReference (18 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 14 of android.database.ContentObserver$Transport (14 unique instances) 12-20 16:06:49.764 4440 4440 F DEBUG : 11 of android.view.ViewRootImpl$W (11 unique instances) ... 12-20 16:06:49.764 4440 4440 F DEBUG : backtrace: 12-20 16:06:49.764 4440 4440 F DEBUG : #00 pc 00039baa /apex/com.android.runtime/lib/bionic/libc.so (abort+138) (BuildId: b25d939cf297d12a048279f5c9ec411e) 12-20 16:06:49.764 4440 4440 F DEBUG : #01 pc 005364b1 /apex/com.android.art/lib/libart.so (art::Runtime::Abort(char const*)+1360) (BuildId: 6dc72c2cbe2cf0489266cd603215f081) 12-20 16:06:49.764 4440 4440 F DEBUG : #02 pc 00023837 /apex/com.google.mainline.primary.libs@340941000/lib/libbase.so/2baee144307110a2b9a7fffc26bfdca189fe29b8266623afb93ed899028350f0708609923037edb06ca3f04aad0e2a06ef79abe9df8628423a3f13dfbde5f670/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_0::__invoke(char const*)+46) (BuildId: 959b00e687b93fff2e345580c1584040) 12-20 16:06:49.764 4440 4440 F DEBUG : #03 pc 000230d7 /apex/com.google.mainline.primary.libs@340941000/lib/libbase.so/2baee144307110a2b9a7fffc26bfdca189fe29b8266623afb93ed899028350f0708609923037edb06ca3f04aad0e2a06ef79abe9df8628423a3f13dfbde5f670/libbase.so (android::base::LogMessage::~LogMessage()+226) (BuildId: 959b00e687b93fff2e345580c1584040) 12-20 16:06:49.764 4440 4440 F DEBUG : #04 pc 001dde43 /apex/com.android.art/lib/libart.so (art::JavaVMExt::AddGlobalRef(art::Thread*, art::ObjPtr<art::mirror::Object>)+234) (BuildId: 6dc72c2cbe2cf0489266cd603215f081) 12-20 16:06:49.764 4440 4440 F DEBUG : #05 pc 00470853 /apex/com.android.art/lib/libart.so (art::JNI<true>::NewGlobalRef(_JNIEnv*, _jobject*)+530) (BuildId: 6dc72c2cbe2cf0489266cd603215f081) 12-20 16:06:49.764 4440 4440 F DEBUG : #06 pc 0041729d /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::CheckJNI::NewRef(char const*, _JNIEnv*, _jobject*, art::IndirectRefKind) (.__uniq.99033978352804627313491551960229047428)+588) (BuildId: 6dc72c2cbe2cf0489266cd603215f081) 12-20 16:06:49.764 4440 4440 F DEBUG : #07 pc 00002f6a <anonymous:d83c0000> Hope this helps someone! Kind regards, Andy
Code (CSharp): _view.Call("getWindowVisibleDisplayFrame", rect); int visibleHeight = rect.Call<int>("height"); Does this still work? On Realme visibleHeight equals always 200000