Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>there is a method in the Browser app source code, :</p> <pre><code>public boolean shouldOverrideUrlLoading(WebView view, String url) { ... } </code></pre> <p>After a url clicked and it's not yet starting to load:</p> <ol> <li><p>converts the url to intent</p> <pre><code>Intent intent; // perform generic parsing of the URI to turn it into an Intent. try { intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); } catch (URISyntaxException ex) { Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage()); return false; } </code></pre></li> <li><p>if it don't start with market:// (or some predefined schemes), try startActivityIfNeeded()</p> <pre><code>intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setComponent(null); try { if (startActivityIfNeeded(intent, -1)) { return true; } } catch (ActivityNotFoundException ex) { // ignore the error. If no application can handle the URL, // eg about:blank, assume the browser can handle it. } </code></pre></li> </ol> <p>It's very useful information! I re-play the situation in a simple code:</p> <pre><code>Intent intent = Intent.parseUri("mycam://http://camcorder.com", Intent.URI_INTENT_SCHEME); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setComponent(null); System.out.println(intent); </code></pre> <p>The result will provide clues for me to write an activity with the intent-filter:</p> <pre><code> &lt;activity android:name=".MyCamActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;category android:name="android.intent.category.BROWSABLE" /&gt; &lt;data android:scheme="mycam" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>PS. don't forget the <strong>android.intent.category.DEFAUL</strong> .</p> <p>Finally, your Activity can invoke by mycam:// scheme</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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