UnityPlayerActivity

Hello!

I am writing a java method - helper for a plugin and I need to call a method that expects an UnityPlayerActivity argument. I am no longer in the extended class of Unity activity and I would like to know where can I get the UnityPlayerActivity argument from.

I am also using

Activity ac = com.unity3d.player.UnityPlayer.currentActivity;

but I understand ac cannot be cast to UnityPlayerActivity.

I am also using Prime31. FYI

I appreciate all the help!

Have a great day!

Why can’t you cast ?

This code seems to be OK:

Activity activity = UnityPlayer.currentActivity;
UnityPlayerActivity unityActivity = (UnityPlayerActivity)activity;

What you get from the currentActivity call is the main activity for the game. It is returned as an Activity reference, but it should be derived from UnityPlayerNativeActivity (unless you’re running some kind of a weird & complex scenario where Unity is being loaded into some app).