Is there an alternative to the getContext in UnityPlayerActivity?
I want the code as shown below.
Activity.getContext()
Is there an alternative to the getContext in UnityPlayerActivity?
I want the code as shown below.
Activity.getContext()
answer from here
using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
            playerActivityContext = actClass.GetStatic< AndroidJavaObject >("currentActivity");
        }
or you can use code below from here
public class Main extends UnityPlayerActivity {
    public static Context mContext;
    @Override
    protected void onCreate(Bundle bundle)
    {
            super.onCreate(bundle);
            mContext = this;
    }
}
 
    
    getContext() is not defined in an Activity. It's used in a View to get a reference to the enclosing context(an Activity).
Please read below Answer .I hope it will helps you.
Difference between getContext() , getApplicationContext() , getBaseContext() and "this"
 
    
    