title: Unity3d Should I cache AndroidJavaObject instance?
body: <p>I am creating simple Android plugin for Unity3D game to show toasts and native popups. When I want to call methods from Java class I use AndroidJavaClass and AndroidJavaObject like in Unity documentation:</p>
  
  <pre><code>        AndroidJavaObject bridge = new AndroidJavaObject(CLASS_NAME);
          AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
          AndroidJavaObject act = jc.GetStatic&lt;AndroidJavaObject&gt;("currentActivity"); 
          act.Call("runOnUiThread", new AndroidJavaRunnable(() =&gt;
          {
              bridge.CallStatic(methodName, args);
          }));
  </code></pre>
  
  <p>Unity documentation (<a href="https://docs.unity3d.com/Manual/AndroidJARPlugins.html" rel="nofollow noreferrer">https://docs.unity3d.com/Manual/AndroidJARPlugins.html</a> "Best practice when using Java plug-ins with Unity") recommended to use using statement like</p>
  
  <pre><code>using (AndroidJavaClass cls = new AndroidJavaClass("java.util.Locale")) { 
      using(AndroidJavaObject locale = cls.CallStatic&lt;AndroidJavaObject&gt;("getDefault")) { 
          Debug.Log("current lang = " + locale.Call&lt;string&gt;("getDisplayLanguage")); 
      } 
  }
  </code></pre>
  
  <p>but said that this is "computationally expensive methods".</p>
  
  <p>Question: Should I cache instances of AndroidJavaClass and AndroidJavaObject or not?</p>
  
  <p>Thanks for answers</p>