Processing of several small feature (3) wtai type URLs in android browser

Source: Internet
Author: User

######################################## #####

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.