本文整理了Java中android.webkit.WebView.getSettings()
方法的一些代码示例,展示了WebView.getSettings()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.getSettings()
方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:getSettings
暂无
代码示例来源:origin: stackoverflow.com
WebView webView = new WebView( context );
webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
webView.getSettings().setAppCachePath( getApplicationContext().getCacheDir().getAbsolutePath() );
webView.getSettings().setAllowFileAccess( true );
webView.getSettings().setAppCacheEnabled( true );
webView.getSettings().setJavaScriptEnabled( true );
webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT ); // load online by default
if ( !isNetworkAvailable() ) { // loading offline
webView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
}
webView.loadUrl( "http://www.google.com" );
代码示例来源:origin: stackoverflow.com
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
代码示例来源:origin: RobotiumTech/robotium
public void run() {
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(robotiumWebClient);
}
});
代码示例来源:origin: stackoverflow.com
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
mWebView.loadUrl("http://www.yahoo.co.in");
setTitle("Yahoo!");
代码示例来源:origin: bingoogolapple/BGARefreshLayout-Android
@Override
protected void processLogic(Bundle savedInstanceState) {
mContentWv.getSettings().setJavaScriptEnabled(true);
mContentWv.loadUrl("https://github.com/bingoogolapple");
}
代码示例来源:origin: pockethub/PocketHub
/**
* Create source editor using given web view
*
* @param view
*/
public SourceEditor(final WebView view) {
WebViewClient client = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (URL_PAGE.equals(url)) {
view.loadUrl(url);
return false;
} else {
UriLauncherActivity.launchUri(view.getContext(), Uri.parse(url));
return true;
}
}
};
view.setWebViewClient(client);
WebSettings settings = view.getSettings();
settings.setJavaScriptEnabled(true);
view.addJavascriptInterface(this, "SourceEditor");
this.view = view;
}
代码示例来源:origin: termux/termux-app
WebSettings settings = mWebView.getSettings();
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setAppCacheEnabled(false);
mWebView.clearCache(true);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
mWebView.loadUrl("https://wiki.termux.com/wiki/Main_Page");
代码示例来源:origin: stackoverflow.com
WebView vistaWeb = (WebView) findViewById(R.id.webview);
vistaWeb.setWebChromeClient(new MyCustomChromeClient(this));
vistaWeb.setWebViewClient(new MyCustomWebViewClient(this));
vistaWeb.clearCache(true);
vistaWeb.clearHistory();
vistaWeb.getSettings().setJavaScriptEnabled(true);
vistaWeb.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
代码示例来源:origin: stackoverflow.com
WebView web = (WebView)findViewById(R.id.web);
WebSettings webSettings = web.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setGeolocationEnabled(true);
webSettings.setSupportMultipleWindows(true); // This forces ChromeClient enabled.
web.setWebChromeClient(new WebChromeClient(){
@Override
public void onReceivedTitle(WebView view, String title) {
getWindow().setTitle(title); //Set Activity tile to page title.
}
});
web.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
代码示例来源:origin: aa112901/remusic
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_top, container, false);
webView = (WebView) view.findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36");
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url); // 根据传入的参数再去加载新的网页
return true; // 表示当前WebView可以处理打开新网页的请求,不用借助系统浏览器
}
});
webView.loadUrl("http://music.163.com/#/discover/toplist?id=19723756");
return view;
}
}
代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android
private void initWebView() {
mContentWv.getSettings().setJavaScriptEnabled(true);
mContentWv.loadUrl("https://github.com/bingoogolapple");
}
代码示例来源:origin: commonsguy/cw-omnibus
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onViewCreated(@NonNull View view,
@Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getWebView().setWebViewClient(new BeamClient());
getWebView().getSettings().setJavaScriptEnabled(true);
loadUrl("https://google.com");
}
代码示例来源:origin: stackoverflow.com
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);
代码示例来源:origin: airbnb/AirMapView
@SuppressLint({ "SetJavaScriptEnabled", "AddJavascriptInterface" })
@Override public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_webview, container, false);
webView = (WebView) view.findViewById(R.id.webview);
mLayout = (ViewGroup) view;
WebSettings webViewSettings = webView.getSettings();
webViewSettings.setSupportZoom(true);
webViewSettings.setBuiltInZoomControls(false);
webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setGeolocationEnabled(true);
webViewSettings.setAllowFileAccess(false);
webViewSettings.setAllowContentAccess(false);
webView.setWebChromeClient(new GeoWebChromeClient());
AirMapType mapType = AirMapType.fromBundle(getArguments());
webView.loadDataWithBaseURL(mapType.getDomain(), mapType.getMapData(getResources()),
"text/html", "base64", null);
webView.addJavascriptInterface(new MapsJavaScriptInterface(), "AirMapView");
return view;
}
代码示例来源:origin: stackoverflow.com
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
setContentView(webView);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
webView.addJavascriptInterface(new MyJavascriptInterface(), "MyClient");
}
代码示例来源:origin: stackoverflow.com
setContentView(R.layout.browser);
WebView browser = (WebView)findViewById(R.id.browser_window);
browser.getSettings().setJavaScriptEnabled(true);
browser.addJavascriptInterface(new JavaScriptInterface(), "HTMLOUT");
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
代码示例来源:origin: stackoverflow.com
public class WebViewDemo extends Activity {
private WebView webView;
Activity activity ;
private ProgressDialog progDailog;
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
activity = this;
progDailog = ProgressDialog.show(activity, "Loading","Please wait...", true);
progDailog.setCancelable(false);
webView = (WebView) findViewById(R.id.webview_compontent);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
progDailog.show();
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
progDailog.dismiss();
}
});
webView.loadUrl("http://www.teluguoneradio.com/rssHostDescr.php?hostId=147");
}
代码示例来源:origin: liuguangqiang/SwipeBack
private void initViews() {
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://github.com");
}
代码示例来源:origin: commonsguy/cw-omnibus
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
browser=(WebView)findViewById(R.id.browser);
browser.getSettings().setJavaScriptEnabled(true);
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
view.loadUrl(url);
return(true);
}
});
visit(getIntent());
}
代码示例来源:origin: stackoverflow.com
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Browser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.BrowserLayout);
String loadUrl = "http://www.google.com/webhp?hl=en&output=html";
// initialize the browser object
WebView browser = (WebView) findViewById(R.id.webview);
browser.getSettings().setLoadWithOverviewMode(true);
browser.getSettings().setUseWideViewPort(true);
try {
// load the url
browser.loadUrl(loadUrl);
} catch (Exception e) {
e.printStackTrace();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!