2016-08-05 63 views
-1

我已經集成在我的Android應用程序中關注我們的Snapchat,並在我的默認網絡視圖中顯示https://www.snapchat.com/add/danubeco網址。這在谷歌瀏覽器中正常工作,但無法加載到設備的默認瀏覽器中。這是在Web視圖中嘗試的錯誤 - 「Uncaught TypeError:Array.from不是函數」,來源:https://www.snapchat.com/deeplink/static/js/sc-web-frame.js。我已經嘗試了幾種設備,發現相同,但事情是它在IOS中完全正常工作。我附上了錯誤的網頁視圖截圖。請提出我可以解決問題的方法。屏幕截圖所示Snapchat Url加載問題

URL - snapchat://添加/ danubeco sc_referrer = &鏈路=%2Fadd%2Fdanubeco & sc_ua = Mozilla的%2F5.0 +%28Linux%3B +的Android + 6.0%3B +的Android + SDK? +內置+爲+ 86 +版本%2FMASTER%3B + WV%29 +爲AppleWebKit%2F537.36 +%28KHTML%2C +像壁虎+ 29%+版本%2F4.0 +鍍鉻%2F44.0.2403.119 +手機+ Safari%2F537.36 & cid = b69e8a19-adf5-4209-9600-a26c0d5e0485

我簡單地在xml中使用web視圖,並在java類中編寫下面的代碼。

webView = (WebView) root.findViewById(R.id.webView); 
webView.setKeepScreenOn(true); 
webView.getSettings().setLoadsImagesAutomatically(true); 
webView.getSettings().setDomStorageEnabled(true); 
webView.getSettings().setJavaScriptEnabled(true); 
webView.getSettings().setLoadWithOverviewMode(true); 
webView.getSettings().setUseWideViewPort(true); 
webView.getSettings().setBuiltInZoomControls(true); 
webView.getSettings().setSupportZoom(true); 
webView.setWebViewClient(new MyWebClient()); 
webView.loadUrl(url); 

任何形式的幫助都是可觀的。

謝謝。

enter image description here

+0

這不是一個URL。它以'snapchat'開始,而不是'http'或'https'。它應該只能使用snapchat App打開。 – Joshua

+0

你不應該使用'Intent'來代替WebView嗎? – xdevs23

+0

我需要在我的web視圖中加載https://www.s∙∙∙∙∙∙∙∙∙∙∙∙∙∙/add/danubecoURL。我遇到第二次通過WebViewClient類的shouldOverrideUrlLoading函數 –

回答

0

請嘗試對shouldOverrideUrlLoading無法加載URL,並把條件假這是工作完美

WebSettings settings = webview.getSettings(); 
    settings.setJavaScriptEnabled(true); 
    //ws.setJavaScriptEnabled(true); 
    settings.setJavaScriptCanOpenWindowsAutomatically(true); 
    webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); 



webview.setWebViewClient(new WebViewClient() { 

     public boolean shouldOverrideUrlLoading(WebView view, String url) { 


      if(url.startsWith("http:") || url.startsWith("https:")) { 
       return false; 
      } 
      // Log.i(TAG, "Processing webview url click..."+url); 
     // view.loadUrl(url); 

      return true; 
     } 


     public void onPageFinished(WebView view, String url) { 
      Log.e(TAG, "Finished loading URL: " + url); 
      if (progressBar.isShowing()) { 
       progressBar.dismiss(); 
      } 


     } 


     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 



     } 
    }); 

    webview.loadUrl("https://www.snapchat.com/add/danubeco"); 
+0

這並沒有解決與我的問題與snapchat。任何其他建議? – akbas

+0

將setJavaScriptEnabled更改爲false對我有用。 – Chowdary102