- Home /
Question by
yashesh · Dec 08, 2014 at 01:07 PM ·
androidbackgroundcontexturl schemes
How to get Updated Context in Unity3D Android when app is open from Backgroung?
Hello All,
I am trying to get URL data when Unity3D android app is open from URL scheme. To get data which is come in URL i have written below in Unity3D :
using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
AndroidJavaObject context = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
String dataString = context.Call<AndroidJavaObject>("getIntent").Call<String>("getDataString");
Debug.LogError ("URL Data " +dataString );
I am able to get URL data but it always remain same if i am opening app from URL scheme or without URL scheme. So i guess the context is not updating when i am opening the app from background state.
Please provide me some suggestion to come out from this problem.
Thanks Yashesh
Comment
Answer by kirillrybin · Apr 20, 2015 at 09:48 AM
Add this code to Main Activity class
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
Hi, could you explain in more detail how to do this? Thanks!