In order to have access to this function, you have to include classes.jar from the <UnityInstallDirectory>\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Classes directory into your Android Studio project then import it with import com.unity3d.player.UnityPlayer; in the Android Studio Project.