0
我已經安裝了xampp並設置了「Microsoft LoopBack Adaptor」,並且能夠在我的活動onCreate方法中使用以下snipet代碼訪問我的網頁「http://localhost/Apryx/audiovideo/」。WebView在瀏覽器中保持打開10.0.2.2
WebView mainWebView = (WebView) findViewById(R.id.act1WebView);
mainWebView.getSettings().setAppCacheMaxSize(5 * 1024 * 1024); // 5MB
mainWebView.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath());
mainWebView.getSettings().setAllowFileAccess(true);
mainWebView.getSettings().setAppCacheEnabled(true);
mainWebView.getSettings().setJavaScriptEnabled(true);
mainWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); // load online by default
if (!isNetworkAvailable()) { // loading offline
mainWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
mainWebView.loadUrl("http://10.0.2.2/Apryx/audiovideo");
問題是,它不斷失控開放瀏覽器,我希望它在webView的應用程序的打開。