Closed SayChunKim closed 2 years ago
This question is out-of-scope for this forum because it is about how to use the library and not regarding a feature request or a bug report.
My knowledge of Unity is very limited, but I don't think these two lines are correct:
beaconManager = new AndroidJavaClass("org.altbeacon.beacon.BeaconManager");
//call method via Unity ScriptingAPI
beaconManager.CallStatic("getInstanceForApplication", context);
It appears that the first line constructs a new instance of the object from the class and the second line makes a call to the constructed object. The error message you show is about there not being an instance method called "getInstanceForApplication". I suspect there is a different way in Unity to call a static method on a class. Again, I could be wrong -- I am no Unity expert.
Since this is out-of-scope, I am closing this issue. Please open a question on StackOverflow.com and I will be happy to assist there. Since my knowledge of Unity is very limited, other members will likely be able to help more.
This question is out-of-scope for this forum because it is about how to use the library and not regarding a feature request or a bug report.
My knowledge of Unity is very limited, but I don't think these two lines are correct:
beaconManager = new AndroidJavaClass("org.altbeacon.beacon.BeaconManager"); //call method via Unity ScriptingAPI beaconManager.CallStatic("getInstanceForApplication", context);
It appears that the first line constructs a new instance of the object from the class and the second line makes a call to the constructed object. The error message you show is about there not being an instance method called "getInstanceForApplication". I suspect there is a different way in Unity to call a static method on a class. Again, I could be wrong -- I am no Unity expert.
Since this is out-of-scope, I am closing this issue. Please open a question on StackOverflow.com and I will be happy to assist there. Since my knowledge of Unity is very limited, other members will likely be able to help more.
Thank you, i have managed to get it worked
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext");
beaconManager = new AndroidJavaClass("org.altbeacon.beacon.BeaconManager");
beaconManager.CallStatic<AndroidJavaObject>("getInstanceForApplication", context);
beaconStatusLog.text = "Initialized";
Thanks
Hi i actually trying to import aar / module of AltBeacon into Unity project but encountered certain error
Expected behavior
Assuming beaconManager able to get instance along with applicationContext via
CallStatic
method ofAndroidJavaClass
of UnityActual behavior
Steps to reproduce this behavior
build.gradle
,AndroidManifest.xml
as the android studio project in Unity ProjectOnClick
listener in Unity SceneMobile device model and OS version
Huawei Nova 4 unrooted VCE-L22 Android version 10
Android Beacon Library version
2.19.3
IMPORTANT: This forum is reserved for feature requests or reproducible bugs with the library itself. If you need help with using the library with your project, please open a new question on StackOverflow.com.