Open Android App from URL

I have a game with a level editor.

I hope that users can share this levels.

The idea is generate a URL with a intent that open the game, and the level.

(Or if the user dont have the game installed, open a playstore url)

But i have no idea of how to do this.

I dont know how to open the game by a link in the navegator and dont know how to “pass” a param to the game to say open the level “X”.

I read about intent, but people are using android studio, java, manifest and other things that i dont know if i need or not…

Someone did something like this?

Im lost in this area :S

Hello,

I’ve just run into a similar issue, and I could figure out how to open the App from a URL, at least.

First, open your .apk build in the Android Studio and edit the AndroidManifest file in there. In my case, my app bundle identifier is “com.vizAR.OppaAR” and I wanted to open the app by accessing “www.eduardo-cg.com/test”, so I add this info into the AndroidManifest, inside my main activity:

<intent-filter>
                <action
                    android:name="android.intent.action.VIEW" />
                <category
                    android:name="android.intent.category.DEFAULT" />
                <category
                    android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="http"
                    android:host="www.eduardo-cg.com"
                    android:path="/test" />
</intent-filter>

And at my site I created a button with the following html code:

<a href="intent://www.eduardo-cg.com/test#Intent;scheme=http;package=com.vizAR.OppaAR;end;">Open App</a>

So when I click at the button, it opens the app, if it’s installed on the phone, or the PlayStore, if it isn’t.

I still haven’t figure out how to pass a param to the game, but it’s the first step, anyway :wink: If you did resolve that, please tell me.

Good luck!

Hi, here my solution working for me to complete cronem answer. First , you complete URL with args like this for a string in this example

 <a href="intent://www.eduardo-cg.com/test#Intent;scheme=http;package=com.vizAR.OppaAR;S.namestring=mystring;end;">Open App</a>

The “S” at the beginning of the “namestring” parameter defines it as a String. Other types can be:

String => ‘S’ Boolean =>‘B’ Byte => ‘b’ Character => ‘c’ Double => ‘d’ Float => ‘f’ Integer => ‘i’ Long => ‘l’ Short => ‘s’

then create a start code like this example :

public class getExtraName : MonoBehaviour {

// Use this for initialization
void Start () {

  string yourname = "";

  AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  AndroidJavaObject currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

  AndroidJavaObject intent = currentActivity.Call<AndroidJavaObject>("getIntent");
  bool hasExtra = intent.Call<bool>("hasExtra", "namestring");


  if (hasExtra)
  {
      AndroidJavaObject extras = intent.Call<AndroidJavaObject>("getExtras");
      yourname = extras.Call<string>("getString", "namestring");            

  }

}
}

Hope helpfull

Add comment · Share

Thanks to both.
Finally, im using the deep link plugin.
In the plugin documentation, it say about use a url like this:

test

But if you want that Play Store open if the aplication is not intalled, you can write this:

test2

I noticed that are a conflict whit manifest.xml if you use google play services pluggin, im not using services for the moment, but in future i need to study how to resolve this issue…