- Home /
How to use AndroidJavaObject/AndroidJavaClass
Hi.. I want to create plugin for Android Unity Application. I read official tutorial and if i'm not wrong we can create plugin using 3 option. Native way using C++, using Java and NDK and using AndroidJavaObject & AndroidJavaClass
I want to make plugin using AndroidJavaObject but i can't find an example in that tutorial. Does anyone know where i can find an example project for that ? I can't find example project using AndroidJavaObject in there.
I also read Integrating Unity with Eclipse Tutorial, if i want to make plugin using AndroidJavaObject did i need following that tutorial too ?
This isn't really a tutorial as such but I found this to be useful. http://forum.unity3d.com/threads/87959-FlurryAgent-wrapper-for-Unity-3.2. The c# file included shows how it's calling functions within the flurry .jar file. Note that AndroidJavaObject & AndroidJavaClass are only used to communicate with your plugin. You'll still need to write the plugin in Java. If you want to send messages back to Unity from your plugin you will need to use UnityPlayer.UnitySend$$anonymous$$essage.
Answer by Raigex · Jul 13, 2012 at 06:15 PM
If you still need any help or for anyone that might stumble upon this. I just spend a couple hours looking for an answer to the plugins, found nothing and then figured it out via trial and error.
If you download the JavaPluginProject and import it into a project ( I suggest an empty one for testing purposes) Then look at CallJavaCode.cs you will find that it only calls jni libraries.
But i have basically found using plugin tutorial from unity and some trial and error how you call functions from from those classes.
AndroidJavaCLass only calls an instance of an activity (it does not create it)
AndroidJavaObject creates a new object class (basically like calling new Class.class)
Then from an object (eg; AndroidJavaObject obj) you call obj.call("methodName") and use ("methodName", arg1,...,argn) if there is any argumants necessary.
will edit when i have a full tutorial up.
I don't think this explanation is correct: AndroidJavaClass only calls an instance of an activity? that is not right.
Answer by ershadd · Mar 07, 2020 at 07:13 AM
to anyone still searching here is a helpful link : https://medium.com/@agrawalsuneet/native-android-in-unity-8ebfb42edfe8
Your answer
Follow this Question
Related Questions
Android Unity Plugin problem 0 Answers
Inner-active Ads Crashes 0 Answers
Unity-Android Plugin (Black Screen) 1 Answer