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
0
Question by unity fly · Jan 27, 2014 at 12:46 PM · nativeandroidjavaobject

How call a Android native class with implements from unity ?

Hi All,

we are creating an application in unity using Android's Eclipse project.

In Eclipse project , we have a class like

 package com.unity3d.player;
 public class TestProjectActivity extends unityPlayerActivity{

from Unity we are calling the above native class using below code. working perfect

 AndroidJavaClass testClass = new AndroidJavaClass("com.unity3d.player.TestProjectActivity");

But, if i have a class like below

 public class TestProjectActivity extends UnityPlayerActivity implements ConnectionCallbacks, OnConnectionFailedListener, OnClickListener{

from unity if i call like

 AndroidJavaClass testClass = new AndroidJavaClass("com.unity3d.player.TestProjectActivity");

am getting an error,

 caused by: java.lang.classnotfoundException: com.unity3d.player.TestProjectActivity

What was the problem ? how to call

 public class TestProjectActivity extends UnityPlayerActivity implements ConnectionCallbacks, OnConnectionFailedListener, OnClickListener{ 

?

can anyone suggest ?

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by gfoot · Jan 27, 2014 at 02:15 PM

Try putting a copy of the google-play-services.jar file into your Plugins/Android folder alongside your own code jar file. I haven't used it myself but from the documentation it sounds like this is what they expect you to do.

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
avatar image
0

Answer by VamshiKrishnaP · Jan 28, 2014 at 07:53 AM

@GFOOT , Thanks for the reply. placed google-play-services.jar in Plugins/Android folder along with my code jar file.

the ClassFoundException error was gone.

Now i have to Call a method which is in my Eclipse project

 public void sharePhoto(final String textPath, final String imagePath)
     {
 
     }


From unity, am calling like

 if(GUI.Button (new Rect(150,150,100,50),"Click")){
             AndroidJavaClass testClass = new AndroidJavaClass("com.unity3d.player.TestProjectActivity");
             testClass.Call<AndroidJavaObject>("sharePhoto","hai Sir","http://stereo.gsfc.nasa.gov/beacon/latest_256/ahead_euvi_195_latest.jpg");        
         }

am getting an error like alt text

can you help on this ? Thank you in Advance.


screen shot 2014-01-28 at 11.37.41 am.png (66.9 kB)
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
avatar image
0

Answer by gfoot · Jan 28, 2014 at 09:15 AM

You should post a separate question really, but the answer is that your Java method doesn't return a value so when you call it you should not specify the generic argument. Just call it like this:

 testClass.Call("sharePhoto","hai Sir","http://stereo.gsfc.nasa.gov/beacon/latest_256/ahead_euvi_195_latest.jpg");
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 VamshiKrishnaP · Feb 01, 2014 at 09:02 AM 0
Share

@gfoot , please refer the question at http://answers.unity3d.com/questions/629672/how-to-call-a-android-native-class-with-implements.html

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

20 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

What is the best way to integrate native XCODE 0 Answers

Tutorials or info dealing with post build process? 3 Answers

Is it possible to render custom objects in the Unity game window using native (opengl) code ? 1 Answer

native android plugin 0 Answers


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