Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:14:35+00:00 2026-06-14T06:14:35+00:00

i have calling java function from my unity code. I have both static &

  • 0

i have calling java function from my unity code.
I have both static & non-static type of functions in my java class
To access first static function, i used:

AndroidJavaClass plugin = new AndroidJavaClass("com.android.test.TestActivity");
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");        
plugin.CallStatic("InstantiateMe", qwe);

above code is running fine, but after this , when i m trying to execute my non static function, its not actually executing.. Not even giving any exception or error..

My code to call non-static function

AndroidJavaClass plugin = new AndroidJavaClass("com.android.test.TestActivity");
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");        
plugin.Call("Enable", qwe);

Help me guyz. i stucked here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:14:36+00:00Added an answer on June 14, 2026 at 6:14 am

    use your “activity” variable for non-static calls: activity.Call("Enable", qwe);
    There is example of static and non-static functions calls:

    public class Caller {
      private readonly AndroidJavaClass _ActivityClass;
      private readonly AndroidJavaObject _ActivityObject;
      private readonly AndroidJavaClass _MyActivityClass; 
    
      public Caller() {
        _ActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        _MyActivityClass = new AndroidJavaClass("com.example.u2aTest.MyMainActivity"); 
    
        _ActivityObject = _ActivityClass.GetStatic("currentActivity");
        // AndroidJavaObject my_activity_object = _MyActivityClass.GetStatic("currentActivity"); //doesn't work
      }
    
      public void MakeTestCalls() {
        _ActivityObject.Call("testVoid"); // works fine
        //_ActivityClass.CallStatic("testVoidStatic"); // doesn't works
       _MyActivityClass.CallStatic("testVoidStatic"); // works fine
        //_ActivityObject.CallStatic("testVoid"); // doesn't work on some divices
    
       //public int testInt(int intValue)
       int iresult = _ActivityObject.Call<int>("testInt", 999);
    
       //public String testStringString(String paramValue)
       String sresult = _ActivityObject.Call<String>("testStringString", "s2");      
    
       //public static int testIntStatic(int intValue) 
       iresult = _MyActivityClass.CallStatic<int>("testIntStatic", 999);
    
       //public static String testStringStringStatic(String paramValue)
       sresult =_MyActivityClass.CallStatic<String>("testStringStringStatic", "s1");
      }
    }
    

    Take a look on example of Android plugin for Unity3D for detailes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with calling an overriden method from java class. I have
I am calling a function from my java code and i am getting this
I'm upgrading from ColdFusion 8 to ColdFusion 9. I have a Java class that
I have a json which is return from the java code. I use toJSON
I have a Java function which returns a singleton instance of a Class public
I have a function which returns array and I am calling this function from
I have stand alone Java Application with Spring 3.0. I am calling REST service
Java 6 API question. Does calling LockSupport.unpark(thread) have a happens-before relationship to the return
i have a problem calling multiple instance of a class that i have coded
I have the following code (calling a method returning IEnumerable): FibonacciWithLinq.Skip(delegate() { return 5;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.