Getting mUnityPlayers view outside UnityPlayerNativeActivity

i try to get the height of the android keyboard so i created the following method inside UnityPlayerNativeActivity:

public int getKeyBoardHeight(){
Rect aRect = new Rect();
return aRect.height();

With that i get the visible height when the keyboard is open and substract it from screen height to have the keyboard height.

I want to know if it is possible to create a seperate class to do this so i don’t have to change or extend the UnityPlayerNativeActivity?

Unity allows you to define your own custom Activity for you game. It has to subclass UnityPlayerActivity (or UnityPlayerNativeActivity).

On that class, you can define utility methods that you need to access, and then you can call them directly from your script code.

For more information, see this link: Unity - Manual: Create and use plug-ins in Android