2015-04-12 107 views
11

我有一個android的webiew應用程序加載一些網站,但不是我需要它的人。Android的webview將不會加載我的網址,但會加載其他人

我不知道如果這是一個網站主機的問題,或者我可以在我的應用程序中做的事情。基本上我有一個在線投資組合,我想讓自己看起來更好,通過將其構建到應用程序中。投資組合網站包含一個移動版本,因此它已經爲此設置好了,並且可以在手機上的Chrome瀏覽器中正常工作。

它用於與舊網站一起工作,它加載谷歌,所以我知道我有互聯網權限。不知道這是否與我的新網站有關,或者我只是需要改變一些東西才能使其工作。

在Chrome瀏覽器中,它看起來應該是這樣,現在並不好,因爲在我向它添加內容之前,我想先做這件事。 This is how it looks.

這是我主要的應用程序代碼(不能張貼的截圖直接作爲我沒有足夠的代表,不好意思):

package com.broadbentstudios; 

import android.annotation.SuppressLint; 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.KeyEvent; 
import android.webkit.WebView; 
import android.webkit.WebViewClient; 
import com.parse.ParseAnalytics; 

@SuppressLint("SetJavaScriptEnabled") 
public class ParseStarterProjectActivity extends Activity { 

    WebView webView; 
    /** Called when the activity is first created. */ 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     webView = (WebView) findViewById(R.id.mainWebView); 
     webView.setBackgroundColor(0x00000000); 
     webView.setHorizontalScrollBarEnabled(false); 
     webView.getSettings().setJavaScriptEnabled(true); 
     webView.getSettings().setUseWideViewPort(true); 
     webView.loadUrl("http://www.broadbentstudios.com/"); 

     webView.setWebViewClient(new WebViewClient() { 
      @Override 
      public boolean shouldOverrideUrlLoading(WebView view, String url) 
      { 
       view.loadUrl(url); 
       return true; 
      }     
     }); 
    } 

    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
     if ((keyCode == KeyEvent.KEYCODE_BACK) && webView!=null && webView.canGoBack()) { 
      webView.goBack(); 
      return true; 
     } 
     return super.onKeyDown(keyCode, event); 
    }   
    { 
     ParseAnalytics.trackAppOpenedInBackground(getIntent()); 
    }  
} 

我的網站的截圖使用我的應用程序時with the code above.

這裏是logcat

04-12 18:51:45.686: D/PowerManagerService(1196): acquireWakeLockInternal: lock=903227323, flags=0x1, tag="LocationManagerService", ws=WorkSource{1000 com.qualcomm.location}, uid=1000, pid=1196 
04-12 18:51:45.686: D/PowerManagerService(1196): acquireWakeLockInternal: lock=662236910, flags=0x1, tag="LocationManagerService", ws=WorkSource{10013 com.google.android.gms}, uid=1000, pid=1196 
04-12 18:51:45.687: D/PowerManagerService(1196): acquireWakeLockInternal: lock=531027438, flags=0x1, tag="LocationManagerService", ws=WorkSource{10013 com.google.android.gms}, uid=1000, pid=1196 
04-12 18:51:45.687: D/PowerManagerService(1196): releaseWakeLockInternal: lock=959227632 [LocationManagerService], flags=0x0 
04-12 18:51:45.687: D/PowerManagerService(1196): releaseWakeLockInternal: lock=546372682 [LocationManagerService], flags=0x0 
04-12 18:51:45.688: D/PowerManagerService(1196): releaseWakeLockInternal: lock=662236910 [LocationManagerService], flags=0x0 
04-12 18:51:45.688: D/PowerManagerService(1196): releaseWakeLockInternal: lock=531027438 [LocationManagerService], flags=0x0 
04-12 18:51:45.689: D/PowerManagerService(1196): releaseWakeLockInternal: lock=197382963 [LocationManagerService], flags=0x0 
04-12 18:51:45.689: D/PowerManagerService(1196): releaseWakeLockInternal: lock=903227323 [LocationManagerService], flags=0x0 
04-12 18:51:45.734: I/LibraryLoader(28664): Time to load native libraries: 34 ms (timestamps 2209-2243) 
04-12 18:51:45.734: I/LibraryLoader(28664): Expected native library version number "",actual native library version number "" 
04-12 18:51:45.747: V/WebViewChromiumFactoryProvider(28664): Binding Chromium to main looper Looper (main, tid 1) {24dd5d0b} 
04-12 18:51:45.747: I/LibraryLoader(28664): Expected native library version number "",actual native library version number "" 
04-12 18:51:45.747: I/chromium(28664): [INFO:library_loader_hooks.cc(108)] Chromium logging enabled: level = 0, default verbosity = 0 
04-12 18:51:45.757: I/BrowserStartupController(28664): Initializing chromium process, singleProcess=true 
04-12 18:51:45.758: W/art(28664): Attempt to remove local handle scope entry from IRT, ignoring 
04-12 18:51:45.768: W/AudioManagerAndroid(28664): Requires BLUETOOTH permission 
04-12 18:51:45.769: W/chromium(28664): [WARNING:resource_bundle.cc(304)] locale_file_path.empty() 
04-12 18:51:45.770: I/chromium(28664): [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=59 off=45928 len=3221 
04-12 18:51:45.770: I/chromium(28664): [INFO:aw_browser_main_parts.cc(76)] Loading webviewchromium.pak from, fd:60 off:390788 len:1143511 
04-12 18:51:45.775: D/libEGL(28664): loaded /vendor/lib/egl/libEGL_adreno.so 
04-12 18:51:45.776: D/libEGL(28664): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so 
04-12 18:51:45.788: D/libEGL(28664): loaded /vendor/lib/egl/libGLESv2_adreno.so 
04-12 18:51:45.803: I/Adreno-EGL(28664): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1.C2.05.00.00.046.002_msm8974_LA.BF.1.1.1.C2__release_AU() 
04-12 18:51:45.803: I/Adreno-EGL(28664): OpenGL ES Shader Compiler Version: E031.25.03.00 
04-12 18:51:45.803: I/Adreno-EGL(28664): Build Date: 01/06/15 Tue 
04-12 18:51:45.803: I/Adreno-EGL(28664): Local Branch: mybranch6793908 
04-12 18:51:45.803: I/Adreno-EGL(28664): Remote Branch: quic/LA.BF.1.1.1.c2 
04-12 18:51:45.803: I/Adreno-EGL(28664): Local Patches: NONE 
04-12 18:51:45.803: I/Adreno-EGL(28664): Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1.C2.05.00.00.046.002 + NOTHING 
04-12 18:51:45.868: W/chromium(28664): [WARNING:data_reduction_proxy_settings.cc(328)] SPDY proxy OFF at startup 
04-12 18:51:45.890: W/art(28664): Attempt to remove local handle scope entry from IRT, ignoring 
04-12 18:51:45.895: W/AwContents(28664): onDetachedFromWindow called when already detached. Ignoring 
04-12 18:51:45.917: E/QCOMSysDaemon(28750): Can't open /dev/block/platform/msm_sdcc.1/by-name/bootselect: (No such file or directory) 
04-12 18:51:45.917: I/QCOMSysDaemon(28750): Starting qcom system daemon 
04-12 18:51:45.917: E/Diag_Lib(28750): Diag_LSM_Init: Failed to open handle to diag driver, error = 2 
04-12 18:51:45.917: E/QCOMSysDaemon(28750): Diag_LSM_Init failed : 0 
04-12 18:51:45.953: D/OpenGLRenderer(28664): Render dirty regions requested: true 
04-12 18:51:45.956: D/Atlas(28664): Validating map... 
04-12 18:51:45.962: E/com.parse.push(28664): successfully subscribed to the broadcast channel. 
04-12 18:51:45.963: D/PowerManagerService(1196): acquireWakeLockInternal: lock=553909931, flags=0x1, tag="Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.broadbentstudios cmp=com.broadbentstudios/com.parse.GcmBroadcastReceiver (has extras) }", ws=null, uid=10221, pid=28664 
04-12 18:51:45.992: I/OpenGLRenderer(28664): Initialized EGL, version 1.4 
04-12 18:51:45.997: D/OpenGLRenderer(28664): Enabling debug mode 0 
04-12 18:51:46.009: D/PowerManagerService(1196): releaseWakeLockInternal: lock=553909931 [Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.broadbentstudios cmp=com.broadbentstudios/com.parse.GcmBroadcastReceiver (has extras) }], flags=0x0 
04-12 18:51:46.029: I/Timeline(28664): Timeline: Activity_idle id: [email protected] time:33412539 
04-12 18:51:46.030: D/PowerManagerService(1196): releaseWakeLockInternal: lock=110279535 [ActivityManager-Launch], flags=0x0 
04-12 18:51:46.038: I/ActivityManager(1196): Displayed com.broadbentstudios/.ParseStarterProjectActivity: +864ms 
04-12 18:51:46.038: I/Timeline(1196): Timeline: Activity_windows_visible id: ActivityRecord{3eff1853 u0 com.broadbentstudios/.ParseStarterProjectActivity t1645} time:33412548 
04-12 18:51:46.055: D/ForegroundUtils(4725): Foreground changed, PID: 4813 UID: 10182 foreground: false 
04-12 18:51:46.055: D/ForegroundUtils(4725): Foreground UID/PID combinations: 
04-12 18:51:46.055: D/ForegroundUtils(4725): UID: 10221 PID: 28664 
04-12 18:51:46.386: D/AbstractMetricsFactoryImpl(28721): record : No data points in metrics event 
04-12 18:51:46.637: W/BindingManager(28664): Cannot call determinedVisibility() - never saw a connection for the pid: 28664 
04-12 18:51:47.134: I/chromium(28664): [INFO:CONSOLE(0)] "'webkitIDBRequest' is deprecated. Please use 'IDBRequest' instead.", source: (0) 
04-12 18:51:47.422: I/chromium(28664): [INFO:CONSOLE(1)] "HARD RESET!!", source: http://www.broadbentstudios.com/application/_output/pb.out.front.js?v=7 (1) 
04-12 18:51:47.440: I/chromium(28664): [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'clear' of null", source: http://www.broadbentstudios.com/application/_output/pb.out.front.js?v=7 (1) 
04-12 18:51:48.338: D/audio_hw_primary(253): out_standby: enter: stream (0xb5801780) usecase(1: low-latency-playback) 

任何幫助將是偉大的,即使它只是如此,我知道如果它是我的應用程序或網站導致的問題。

謝謝。

回答

27

終於找到了很多搜索後的答案。對於處於類似情況的任何人,以及啓用javascript,您還需要通過添加來啓用Dom存儲;

webView.getSettings().setDomStorageEnabled(true); 

將webView更改爲任何你所稱的,你應該很好去。

希望這可以幫助別人。

+0

你先生,讓我的一天:) Thx – luQ

+0

@luQ很高興我能幫忙,花了我幾天才找到這個,所以我知道痛苦哈哈。 –

+0

@LewisBroadbent感謝男人....你是一個很好的開發者....正如你瞭解其他開發者的痛苦......讚賞! –

0

您的網站有個JavaScript錯誤。您是否在共享的日誌中嘗試了一些有關該錯誤的內容?

Uncaught TypeError: Cannot read property 'clear' of null", source: http://www.broadbentstudios.com/application/_output/pb.out.front.js?v=7 (1)

+0

我試圖disbaling JavaScript作爲longshot但沒有幫助,我不認爲它會。我也是一個巨大的小白酒,所以我不確定還有什麼可以嘗試的,我在網上瀏覽過,但人們只是說要添加我已經擁有的互聯網許可。有什麼你可以建議我嘗試?感謝您爲我指出這一點,我大部分都是logcat新手,並且猜想我錯過了它。 –

+0

禁用JavaScript無效,因爲您的網頁可能正在使用它來加載其內容。你需要弄清楚是什麼導致了JavaScript錯誤。另外,您是在模擬器上還是在設備上進行測試?我可以在運行Android 5.0的Chrome應用上加載http://www.broadbentstudios.com/。1這意味着任何應用程序的WebView應該能夠至少在Android 5上打開它。 – Anyonymous2324

+0

是的,我認爲它是,但我仍然放棄了它。這是令人困惑的事情,我正在5.0.2的實際手機上運行它,它在我的Chrome應用程序中運行正常。 –

0

我最近創建一個存儲庫爲Android與處理的沒有互聯網連接的一些錯誤一個基本的Web視圖應用

https://github.com/jgarciabt/SmartWebView

您可以克隆它,並從它啓動應用程序,也許這更容易。

+0

我會看看謝謝。 –

+0

我正在寫一些關於它是如何工作的文檔,所以如果你不急於你可以稍後再檢查它=) – jgarciabt

+0

謝謝,我可能需要,我只是試圖安裝並運行它與我的網址,它只是說不幸的是,SmartWebView已停止,我在logcat中遇到很多錯誤。haha –