15

I want to open third party apps from my web browser. So, I don't have any manifest file or anything.

I have a web page.

I want to have a link which opens the third party app e.g Twitter or Opera.

How do I structure the anchor link to go open that app?

Thank you.

user1581579
  • 323
  • 3
  • 7
  • 14

2 Answers2

36

The basic syntax for an intent based URI is as follows:

intent:
   HOST/URI-path // Optional host
   #Intent;
      package=[string];
      action=[string];
      category=[string];
      component=[string];
      scheme=[string];
   end;

Parsing details available in the Android source.

To launch the ZXing barcode scanner app you can encode your href as follows:

<p>
  <a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end">Take a qr code</a><br>

  <a href="intent://scan/?ret=http%3A%2F%2Fexample.com#Intent;scheme=zxing;package=com.google.zxing.client.android;end">Take a qr code = 10px x 10px</a><br>

  <a href="intent:play/?mediaset=android-phone-rtmp-high&amp;playlisturl=http://www.bbc.co.uk/iplayer/playlist/bbc_one_london#Intent;scheme=bbcmediaplayer;package=air.uk.co.bbc.android.mediaplayer;end">Launch BBC</a>
</p>

The Android manifest defines the scheme to be zxing, the package to be com.google.zxing.client.android and the host data to be scan.

If the activity you are invoking via an intent contains extra data, these too can be included.

Only activities that have category filter android.intent.category.BROWSABLE are able to be invoked using this method as it indicates that the application is safe to open from the browser.

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
Kinlan
  • 16,315
  • 5
  • 56
  • 88
  • 8
    maybe i'm wrong, but somehow i'm missing a reference to https://developer.chrome.com/multidevice/android/intents ;) – klaus Nov 13 '14 at 21:36
  • How can the browser get the barcode scanned by ZXing? – Cristian Ciupitu Jun 03 '15 at 21:26
  • If you want to get the code back when the scanner call the return URL, in the return (or callback) URL you have to add a placeholder with the text "{RAWCODE} . For instance http://www.example.com/scan.html?code={CODE} . The scanner app will call back to that URL with the {CODE} replaced with the actual code. The rest is up to you. Hope it help someone – Victor Salvans Montesó Sep 13 '17 at 09:56
  • @Kinlan I read your blog about this. Do you have downloadable source I can run to test invoking intents from a browser? – gonzobrains Aug 17 '18 at 19:41
  • @Kinlan I'm trying to pass a URL (https://example.com/path) as the URI-path/HOST. What should the format of my URI be in this case? I tried `intent://example.com/path#Intent;...;end` but that doesn't work. – mjsxbo Sep 20 '20 at 13:38
2

This is not generically possible. If other apps have a custom URL handler then you can open that URL, but otherwise you can't.

kabuko
  • 36,028
  • 10
  • 80
  • 93