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 niall1111 · Feb 20, 2014 at 06:31 PM · androidportingintent

Modifying Android intents via C# in Unity

I must admit, I am quite unfamiliar with the Android ecosystem, having spent the last few years working on iOS-only games. Currently doing my first android port, and I need to specify a path to the external OBB file for the publisher SDK we're using. The extent of my direction from them is this:

This path ususlly obtained in runtime by obb-downloader plugin. So all you need is add to the intent of main activity: getIntent().putExtra("KD_OBB_PATH", OBBPath);

I found this obb-downloader plugin for Unity on the asset store, but it's littered with comments about how it does not function in Unity 4.x. And well, that example I got is Java code, and from what I can tell, the "easy" way is to make my own Java plugin for Android specifically to make this single call? I've been trying to avoid that headache and trying to do it right in a Start() function before the rest of my SDK-handling code:

         if (Application.platform == RuntimePlatform.Android) 
         {
             AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
             AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
 
             AndroidJavaClass Environment = new AndroidJavaClass("android.os.Environment");
             string obb_package = currentActivity.Call<string>("getPackageName");
             const string obbPath = "Android/obb";
             string OBBPATH = "";
             using (AndroidJavaObject externalStorageDirectory = Environment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"))
             {
                 string root = externalStorageDirectory.Call<string>("getPath");
                 OBBPATH = String.Format("{0}/{1}/{2}", root, obbPath, obb_package);
                 Debug.Log ("OBBPATH is: " + OBBPATH);
             }
             currentActivity.Call<AndroidJavaObject>("getIntent").Call("putExtra", "KD_OBB_PATH", OBBPATH);
         }

This code is erroring out on the attempt to call "getIntent":

02-20 10:24:16.788: I/Unity(16245): AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='getIntent' signature='()Ljava/lang/Object;' in class Lcom/prime31/UnityPlayerNativeActivity;

I'm having a heck of a time trying to google any solutions to this, so I came here, to my last resort! Any suggestions?

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

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

Porting ios game to android 1 Answer

Porting Android Game(developed in Eclipse) to Unity3D 1 Answer

A node in a childnode? 1 Answer

Unity / QCAR Activity on Android 1 Answer

Sending data using intent from Unity app to Android app 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