-1

I am looking a work around to trigger my Android App with a website hyperlink (from Google Chrome) along with some params as well.

halfer
  • 18,701
  • 13
  • 79
  • 158
  • That is generally called "deep link", you should read this article: https://developer.android.com/training/app-indexing/deep-linking.html – mdelolmo Aug 07 '14 at 14:45

1 Answers1

1

You need to add an <intent-filter> in your AndroidManifest.xml

<intent-filter>
    <data android:scheme="scheme" android:host="host.com" />
    <action android:name="android.intent.action.VIEW" />
</intent-filter>

Link to it in html code like this:

<a href="scheme://host.com/parameter1/parameter2">

When the link is clicked, your app will be launched. You can get the params in you app like this:

// From link: scheme://host.com/foo/bar
Uri myData = getIntent().getData();
String scheme = data.getScheme(); // "scheme"
String host = data.getHost(); // "host.com"
List<String> parameters = data.getPathSegments();
String parameter1 = params.get(0); // "foo"
String parameter2 = params.get(1); // "bar"

Note that you can use http as your scheme to handle ordinary links to a particular host.

Check out this question for additional info, and look at the docs page on intent-filter.

Hope this helps!

Community
  • 1
  • 1
Eoin
  • 791
  • 2
  • 12
  • 24