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
1
Question by Jix · Jan 02, 2015 at 03:55 PM · androidiosnative

Is it possible to pass a parameter from app to unity app

Here's the case, we have a native Android app that's connected to a server and each user has a session id, this app will open a unity app at some point but we need to pass the user's session id from the native app to the unity app. Is this possible?

We don't want make the user re login in the unity app.

We will need to do the same for iOS in the future too

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

2 Replies

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

Answer by pako · Jan 02, 2015 at 05:10 PM

From Eclipse/Android Studio inside Java code, use the UnityPlayer.UnitySendMessage method as described in the notes below the code of Example 3:

http://docs.unity3d.com/Manual/PluginsForAndroid.html

...and detailed in the iOS implementation (see Calling C# / JavaScript back from native code):

http://docs.unity3d.com/Manual/PluginsForIOS.html

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 · Jan 03, 2015 at 09:49 PM 0
Share

This will only work in the same app, e.g: when you have Java code that is packed with your game.

avatar image
0

Answer by liortal · Jan 03, 2015 at 09:54 PM

How are you going to launch the Unity game from the other app ?

On Android, when launching a new Intent, you can supply extra data (extras) to it, that can be picked up from the launched app.

A high level process of how that would work out:

  1. The native android app launches the Unity game using an Intent, and places the session id as an extra (intent.putExtra)

  2. A custom Activity is used for the Unity game, grabbing the sent extras in its onCreate method and storing it.

  3. From Unity (C#) code, access the stored session id (using AndroidJavaObject and the likes) to get the passed value.

Let me know if this is sufficient or whether code samples would be needed.

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 unity040815 · Oct 27, 2015 at 11:03 AM 0
Share

I am facing the same error, could you share the code samples..please

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

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

Related Questions

Overlay a native layer 0 Answers

Need help with image native sharing 0 Answers

Access native android iOS SDK 0 Answers

Native list views on Mobile? 0 Answers

Native look on iOS / Android? 2 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