Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There does not seem to be a good way to do what you want (at least according to my testing with Android 4.0.4; maybe the situation is different with other versions).</p> <h1>Using <code>http:</code> or <code>https:</code> links intercepted by an app</h1> <p>In theory, just using the <code>https://docs.google.com/...</code> link for the document should work for you. According to <a href="https://stackoverflow.com/a/3472228/538937" title="Make a link in the Android browser start up my app?">this answer on StackOverflow</a>, intercepting <code>http:</code> or <code>https:</code> URLs is the proper way to start an app when opening a link from the Android browser. The Google Drive app does exactly this — it registers intent filters for <code>https://drive.google.com</code>, <code>https://docs.google.com</code>, <code>https://spreadsheets.google.com</code> and a bunch of similar URLs (including <code>http:</code> with the same host names). And this actually works — when using the stock Android browser, attempting to open a link pointing to <code>https://drive.google.com</code> results in the chooser popup with the Google Drive app included in the list (together with all installed browsers); selecting Google Drive results in opening the document in the Google Drive editor, as you want.</p> <p>But the problem is that such intercepted HTTP[S] URLs work <strong>only in the stock Android browser</strong> — I have not been able to find any third-party browser which could show the app chooser when following such links. I tested Chrome, Dolphin, Firefox, Light Browser, Opera (including Classic and Mini), UC Browser, and all of them just opened the link internally instead of offering to pass it to the Google Drive app.</p> <h1>Using the <code>intent:</code> URI scheme</h1> <p>There is another way to make a link which starts an Android app — use the <code>intent:</code> URI scheme. I have not been able to find proper documentation for the <code>intent:</code> URI format; of course, the <a href="https://github.com/android/platform_frameworks_base/blob/db6a14cc85cede0769735fdac4da70766989a3ce/core/java/android/content/Intent.java#L6498" rel="nofollow noreferrer" title="android.content.Intent.toUri(int)">source code for the function which generates such URIs</a> is available.</p> <p>For <a href="https://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing" rel="nofollow noreferrer" title="Test document — HTTPS link">your test document</a>:</p> <pre><code>https://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing </code></pre> <p>the corresponding <code>intent:</code> link which opens it in the Google Drive app will be:</p> <pre><code>intent://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.google.android.apps.docs;end </code></pre> <p>A test link with this URI is <a href="http://possiblypublicfiles.s3.amazonaws.com/test%20intent%20link.html" rel="nofollow noreferrer">on a separate page</a> (it is not possible to make an actual link pointing to such URI here).</p> <p>The process of conversion is as follows:</p> <ol> <li><p>Replace starting <code>https:</code> with <code>intent:</code>.</p></li> <li><p>Append intent parameters:</p> <pre><code>#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.google.android.apps.docs;end </code></pre> <p>Here <code>scheme=https</code> correspond to <code>https:</code> in the original URL, so if you want to convert a plain<code>http:</code> URL, this field should be <code>scheme=http</code>. And <code>package=com.google.android.apps.docs</code> is the <em>package name</em> of the app which should handle the link.</p></li> </ol> <p>Now, when such link is followed, the browser should open the Google Drive app directly (without showing the app chooser). However, if the app is not installed, Android will open the Market app instead, and perform a search for the specified package name, so that the user could install the required app.</p> <p>It is also possible to make the <code>intent:</code> link without the <code>package</code> parameter:</p> <pre><code>intent://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;end </code></pre> <p>In this case the behavior should be the same as when the intercepted <code>https:</code> link is followed in the stock Android browser — the app chooser with the Google Drive app and all browser apps will be displayed, and if the Google Drive app is not installed, the user will not be redirected to install it from Market.</p> <p>Unlike intercepted <code>http:</code> and <code>https:</code> links, <code>intent:</code> links work in a wider range of Android browser apps; unfortunately, some browsers do not support them. Results of my testing:</p> <ul> <li>Works: stock Android 4.0.4 browser, Chrome, Light Browser, Opera, Opera Classic.</li> <li>Does not work: Dolphin, Firefox (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=851693" rel="nofollow noreferrer" title="Mozilla Bug #851693: Allow loading URI Intents">feature request is pending</a>), UC Browser.</li> </ul> <p>And, obviously, non-Android browsers would not support such links at all, so you will need to use some kind of browser sniffing if your pages also must be usable for other clients.</p> <h1>Using a custom URI scheme</h1> <p>Some apps use completely nonstandard URI schemes, which might also work from third-party browsers. However, the Google Drive app does not do that, therefore this solution is not suitable for it (unless someone creates a “bridge” app which just passes requests to the Google Drive app).</p> <p>Some browsers could also disallow nonstandard URI schemes except some whitelisted ones (such as <code>market:</code>) due to security concerns; I did not try to test this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload