Open android game from url with parameters

Hi,

I want to make my android game open with a custom link like this:

http://www.example.com/open?custom_param1=val1

and retrieve the information of the custom_param1 and use it on my game. I tried to search info and I got the following setup:

on my game.Build.cs I added this:

string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
            AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", System.IO.Path.Combine(PluginPath, "custom_APL.xml")));

then, the custom_APL.xml is the following:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- init section is always evaluated once per architecture -->
  <init>
    <log text="test"/>
  </init>

  <!-- optional updates applied to AndroidManifest.xml -->
  <androidManifestUpdates>
    <!-- update the GameActivity activity -->
    <loopElements tag="activity">
      <setStringFromAttribute result="activityName" tag="$" name="android:name"/>
      <setBoolIsEqual result="bGameActivity" arg1="$S(activityName)" arg2="com.epicgames.ue4.GameActivity"/>    
      <if condition="bGameActivity">
        <true>
          <!-- Add App Tiles to manifest file. -->
          <addElements tag="$">
            <intent-filter>
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
              <data android:scheme="http" android:host="www.example.com" />
            </intent-filter>
          </addElements>
        </true>
      </if>
    </loopElements>
  </androidManifestUpdates>
  <gameActivityOnCreateAdditions>
    <insert>
      Uri data = this.getIntent().getData();
      if (data != null){ 
        if(data.isHierarchical(){ 
          if(activity != null) {
            if (data.getQueryParameter("custom_param1") != null) {
              String param1 = data.getQueryParameter("custom_param1");
              Log.debug("now what??.");
            }
          }
        }
      }
    </insert>
  </gameActivityOnCreateAdditions>
</root>

I can see that the manifest of my game is getting the intent-filter additions, and when I start the game, I can see the debug line “now what??.” but I have no clue on what to do next. I don’t know how to access the custom_param1 from c++, and also, my game isn’t launching when I click on “http://www.example.com/open?custom_param1=val1” hyperlink

Can someone give me some hint or idea to follow? I’m really confused by this.

Thank you,
David.

You found any solution, how get parametr?

You need to create a trigger function using JNI which can bridge between c++ and java, and when you receive the data from url, you can trigger that function to get data on the android side.

Hey, for solving the issue of that the game is still not open for you.
You need to add this line

<action android:name="android.intent.action.VIEW" />

in the intent filter and add the (autoVerify= “true”) to the Intent-filter
so it would be like this

<intent-filter android:autoVerify= "true">
              <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.example.com" />
</intent-filter>

second you need to get in your devices Settings->Apps->Default Apps->Opening Links->Your App->Supported web addresses
and allow those addresses if they are off.

then it should work for you.

I hope that helped.