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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by MooOooN · Apr 23, 2015 at 01:07 PM · androidunity 4.6androidplugin

How to make Android Plugin for Unity3d

I am trying to build Android Plugin for Unity3D. My Android Project is a Library project and i have used it on different Android Applications. This Library project simply displays a Dialog on my Main Application, having some images. An xml layout is attached to this Dialog to set Image placements.

Now I want to use the same Android Library Project with Unity3D. I have followed a simple tutorial that lets me communicate between Android and Unity3D.

So in Unity3D using AndroidJavaClass, when I call this function to display the dialog containing images, it shows nothing and with no error.

Is there something I should change in my AndroidManifest or what should I change in my code to display this dialoge?

Please Help me out of this.

Update-1

This is the code on Unity3D side this is the bridge Class.

 using UnityEngine;
 using System.Collections;
 
 public class Test : MonoBehaviour
 {
     AndroidJavaClass androidclass = null;
 
     // Use this for initialization
     void Start()
     {
         AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
         AndroidJavaObject activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
 
         androidclass = new AndroidJavaClass("com.mycompany.myproject.androidbridgeclass");
                 
         
     }
 
     void Update()
     {
         if (Input.GetMouseButtonDown(0))
         {
             
         androidclass.CallStatic("displayDialogWithImages");
         }
 
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             Application.Quit();
         }
     }
 }
 

Comment
Add comment · Show 2
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 steakpinball · Apr 23, 2015 at 02:01 PM 0
Share

Can you provide the code you tried?

avatar image MooOooN · Apr 24, 2015 at 06:24 AM 0
Share

code of which side? Dialog appears perfect on android applications. But in Unity3d it doesn't work. I am Uploading Bridge Class Code.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MooOooN · Apr 24, 2015 at 12:54 PM

Ok So that is how I did it.

 if (Input.GetMouseButtonDown(0))
          {
              currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
             {
                 androidclass.CallStatic("displayDialogWithImages");
             }));
          
          }

RunOnUiThread did the job.

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 bhavani0824 · Oct 13, 2016 at 10:55 AM

How to call non static method from android to unity 3d???

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to release global references created when passing strings from java to c# via AndroidJavaProxy interface 0 Answers

IAP Plugins on Android Unity Not Working For Me 1 Answer

Unity4.6.1&Google Play Plugin Freeze Problem On Exit On Android 3 Answers

Starting a activity in Android Library 2 Answers

Passing Audio to an Android service? 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