######################################## #####
This article is original to extreme cold ice, for reprint, please specify the source #################################### #########
On some mobile phones, enter wtai: // wp/mc; 10086 in the url address bar to automatically jump to the page for dialing 10086. Enter wtai: // wp/mc; 10010 to enter the page for dialing 10010. How is this function implemented? I did some research myself.
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.javaindex daeb1de..6bec737 100644--- a/src/com/android/browser/NavigationBarBase.java+++ b/src/com/android/browser/NavigationBarBase.java@@ -172,12 +172,13 @@ public class NavigationBarBase extends LinearLayout implements boolean wap2estore = SystemProperties.getBoolean( "persist.env.browser.wap2estore", false); if ((wap2estore && isEstoreTypeUrl(text))+ || isWtaiTypeUrl(text)) { url = text; } else { url = UrlUtils.smartUrlFilter(text, false); }- Tab t = mBaseUi.getActiveTab(); // Only shortcut javascript URIs for now, as there is special // logic in UrlHandler for other schemas@@ -199,7 +200,19 @@ public class NavigationBarBase extends LinearLayout implements return; } }+ Log.e(TAG,"bar url = " + url);+ if (url != null && t != null && isWtaiTypeUrl(url))+ {+ if(handleWtaiTypeUrl(url))+ {+ return;+ }+ } }+ Intent i = new Intent(); String action = Intent.ACTION_SEARCH; i.setAction(action);@@ -256,6 +269,21 @@ public class NavigationBarBase extends LinearLayout implements } } + private boolean isWtaiTypeUrl(String url) {+ String utf8Url = null;+ try {+ utf8Url = new String(url.getBytes("UTF-8"), "UTF-8");+ } catch (UnsupportedEncodingException e) {+ Log.e(TAG, "err " + e);+ }+ if (utf8Url != null && utf8Url.startsWith("wtai://wp/mc;")) {+ return true;+ }+ return false;+ }+ String utf8Url = null; try {@@ -269,6 +297,21 @@ public class NavigationBarBase extends LinearLayout implements return false; } + private boolean handleWtaiTypeUrl(String url) {+ Intent intent;+ // perform generic parsing of the URI to turn it into an Intent.+ intent = new Intent(Intent.ACTION_VIEW, Uri.parse(WebView.SCHEME_TEL + url.substring(("wtai://wp/mc;").length())));+ try {+ mContext.startActivity(intent);+ } catch (ActivityNotFoundException ex) {+ Log.w("Browser", "No resolveActivity " + url);+ return false;+ }+ return true;+ }+ private boolean handleRtspTypeUrl(String url) { Intent intent; // perform generic parsing of the URI to turn it into an Intent.
The specific principle is to determine the type when the url is passed in, and then implement this function with a new intent.