android browser 的几个小feature (三) wtai类型url的处理
#############################################
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java index 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.
具体原理是在传入url的时候,判断类型,然后new一个intent去实现这个功能。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。