转载自:http://blog.csdn.net/u014369799/article/details/51305788

在WebView中如果使用到支付宝,需要添加以下代码,否则操作系统会将支付宝的URL拦截,导致你打不开支付宝页面。

 

mWebView.setWebViewClient(new WebViewClient(){  
        @Override  
        public boolean shouldOverrideUrlLoading(WebView view, String url) {  
            if( url.startsWith("http:") || url.startsWith("https:") ) {  
                return false;  
            }  
   try{
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));  
            startActivity( intent );  
   }catch(Exception e){}
            return true;  
        }  
    });  

这里要注意的是上面需要加下try catch,因为你传过来的url并不一定是合法的。有可能是打开本地app的url,如果你没有安装,是会导致崩溃的。

 

相关文章:

  • 2021-11-17
  • 2021-04-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-06-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案