there is a method in the Browser app source code, :
public boolean shouldOverrideUrlLoading(WebView view, String url) { ... }
After a url clicked and it's not yet starting to load:
converts the url to intent
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;
}
if it don't start with market:// (or some predefined schemes), try startActivityIfNeeded()
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.
}
It's very useful information! I re-play the situation in a simple 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);
The result will provide clues for me to write an activity with the intent-filter:
<activity android:name=".MyCamActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mycam" />
</intent-filter>
</activity>
PS. don't forget the android.intent.category.DEFAUL .
Finally, your Activity can invoke by mycam:// scheme