Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by ngajay · May 14, 2012 at 11:49 AM · androidpluginandroidjavaobject

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 ?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HazeTI · May 14, 2012 at 03:14 PM 1
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image liortal · May 26, 2014 at 03:23 PM 0
Share

I don't think this explanation is correct: AndroidJavaClass only calls an instance of an activity? that is not right.

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android Unity Plugin problem 0 Answers

Inner-active Ads Crashes 0 Answers

Unity-Android Plugin (Black Screen) 1 Answer

Android Unity Plugin - UnityPause(bool pause) 0 Answers

Android plugin breaks when using receiver. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges