- Home /
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
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):
This will only work in the same app, e.g: when you have Java code that is packed with your game.
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:
The native android app launches the Unity game using an Intent, and places the session id as an extra (intent.putExtra)
A custom Activity is used for the Unity game, grabbing the sent extras in its onCreate method and storing it.
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.
I am facing the same error, could you share the code samples..please
Your answer
Follow this Question
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