Give us as much detail as possible regarding the issue you're experiencing.
Unity Editor version: 2022.2.0b8 :
ML2 OS version: September 2022 B3E.220818.12-R.085 :
MLSDK version: 0.53.3 :
Host OS: Windows 11 : (Windows)
Error: No error. Program stops reading from Java script
** Continuation of App Development: How do I access Android Libraries in Unity C# so the app shows Wifi SSIDs on ML2 device? **
I am trying to sense all Wifi signals in Magic Leap. Unity does not natively seem to read signals through C#. Instead, the solution seems to be creating an Android Studio library, making an AAR and sending to Unity, then using callbacks to the Java code.
There are several YouTube videos that support getting the SSID in Java:
(single, simple):
Creating Android Plugin (AAR) for Unity with Android Toast
However, this file needs to extend from AppCompatActivity. Without this extension, the AAR I included in my Unity's Android/Plugins/unity-module.aar can read simple items like Add(i, j). That is, I can click a UI button in Unity, it reads "var result = _pluginInstance.Call("Add", 10, 10)" through the AAR, and the correct result is displayed in the Magic Leap headset.
However, the reading of the Wifi signals need to use WifiInfo and WifiManager. In Java, when I do not extend AppCompatActivity, these are colored red. When I extend it, it compiles, but my button cannot read the files once it gets to WifiInfo/WifiManager.
I heard several solutions (see my prior ML Forum post in the introduction), which range from:
- Write the C# jni equivalent of java code that would be used for accessing the wifi manager" or
- Create a .aar plugin of that java code, import it into unity and write the C# jni equivalent to invoke the simpler functions of your aar plugin".
I think I am performing #2 above correctly, just getting stuck on Extending the code.
So far, I have tried:
-
Finding UnityPlayer.java (which extends Activity) and instead extending AppCompatActivity, which breaks the code.
-
"Put all the Extended Libraries in Android into Unity's Android/Plugin folder"
Starting AppCompatActivity from Unity C# Script
https://forum.unity.com/threads/starting-appcompatactivity-from-unity-c-script.942679/
... There are tons of External libraries. I included classes.jar into the Plugin folder (read from hovering over the wifimanager import), resulting in no change.
- ...or even "Modifying UnityPlayerActivity":
java - Android UnityPlayerActivity Action Bar - Stack Overflow
It cannot be this hard. Has anyone gotten Magic Leap to read Wifi Signals / RSSI stats? (Basically, all the info in getConnectionInfo()). If so, could you please provide git code, or simple basic steps?
Thanks,
Clint