- Home /
Cannot create null java.lang.Long object
I'm trying to create a Java object (AndroidJavaObject) of type java.lang.Long and initialize it with a null value:
jo = AndroidJavaObject("java.lang.Long", null)
Trying to pass this object to a Java method causes Unity to crash. Same goes when trying to call the object's "toString" method:
Debug.Log("jo: $(jo.Call[of string]('toString'))")
Am I doing it wrong? Or is this a bug?
Note: It is quite possible for Long to hold null. This is not the primitive type "long" (lowercase). And mind the Boo syntax. :)
Answer by oferei · Jul 17, 2013 at 05:17 PM
Ok, I think I figured it out myself. I just passed "null" without using AndroidJavaObject at all:
jc = AndroidJavaClass("com.unity3d.player.UnityPlayer")
jo = jc.GetStatic[of AndroidJavaObject]("currentActivity")
jo.Call("myMethodThatWantsALongClass", null)
Works for me.
Btw, isn't Boo syntax simply cleeean? ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220613110309im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to access methods from nested static java classes 0 Answers
NullReferenceException question. 2 Answers
Main menu camera change script. 1 Answer
Mid point of a object 1 Answer
AndroidJavaObject.Call fails with 'method not found' 1 Answer