本文整理匯總了Java中android.webkit.WebSettings類的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings類的具體用法?Java WebSettings怎麽用?Java WebSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebSettings類屬於android.webkit包,在下文中一共展示了WebSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clearWebViewAllCache
import android.webkit.WebSettings; //導入依賴的package包/類
static void clearWebViewAllCache(Context context, WebView webView) {
try {
AgentWebConfig.removeAllCookies(null);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
context.deleteDatabase("webviewCache.db");
context.deleteDatabase("webview.db");
webView.clearCache(true);
webView.clearHistory();
webView.clearFormData();
clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0);
} catch (Exception ignore) {
//ignore.printStackTrace();
if (AgentWebConfig.DEBUG)
ignore.printStackTrace();
}
}
示例2: openCache
import android.webkit.WebSettings; //導入依賴的package包/類
public void openCache(String cacheDirPath){
//設置緩存模式
mWebSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// 開啟DOM storage API 功能
mWebSettings.setDomStorageEnabled(true);
// 開啟database storage API功能
mWebSettings.setDatabaseEnabled(true);
// 設置數據庫緩存路徑
mWebSettings.setAppCachePath(cacheDirPath);
mWebSettings.setAppCacheEnabled(true);
}
示例3: initWebView
import android.webkit.WebSettings; //導入依賴的package包/類
private void initWebView() {
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
/*使webview能夠加載圖片*/
webSettings.setBlockNetworkImage(false);
webSettings.setAppCacheEnabled(true);
mDialog=new SpotsDialog(this);
mDialog.show();
mWebView.loadUrl(mMessage.getClickUrl());
// mWebAppInterface = new WebAppInterface(this);
// mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
mWebView.setWebViewClient(new MyWebChromeC());
mWebView.setWebChromeClient(new WebChromeClient(){
});
}
示例4: init
import android.webkit.WebSettings; //導入依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
private void init(Context context) {
// 頂部顯示的進度條
mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 7, 0, 0));
Drawable drawable = context.getResources().getDrawable(R.drawable.layer_web_progress_bar);
mProgressBar.setProgressDrawable(drawable);
addView(mProgressBar);
WebSettings webSettings = this.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true); // 是能放大縮小
webSettings.setUseWideViewPort(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);//隱藏
webSettings.setDomStorageEnabled(true);
webSettings.setSupportMultipleWindows(true);
//webSettings.setUseWideViewPort(true);
this.setWebViewClient(mWebViewClientBase);
this.setWebChromeClient(mWebChromeClientBase);
setDownloadListener(new DownloadListener());
this.onResume();
}
示例5: setWebView
import android.webkit.WebSettings; //導入依賴的package包/類
private void setWebView(String product_id) {
if (product_id != null) {
//http://192.168.51.104:8080/atguigu/json/GOODSINFO_URL.json2691
// wbGoodInfoMore.loadUrl(Constants.GOODSINFO_URL + product_id);
wbGoodInfoMore.loadUrl("http://www.atguigu.com");
//覆蓋WebView默認使用第三方或係統默認瀏覽器打開網頁的行為,使網頁用WebView打開
wbGoodInfoMore.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//返回值是true的時候控製去WebView打開,為false調用係統瀏覽器或第三方瀏覽器
view.loadUrl(url);
return true;
}
});
//啟用支持javascript
WebSettings settings = wbGoodInfoMore.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
//優先使用緩存
wbGoodInfoMore.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
}
示例6: onCreate
import android.webkit.WebSettings; //導入依賴的package包/類
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_privacy_policy);
final WebView privacyPolicyWebView = (WebView)findViewById(R.id.privacypolicy);
privacyPolicyWebView.setVisibility(View.VISIBLE);
privacyPolicyWebView.getSettings().setJavaScriptEnabled(true);
privacyPolicyWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
privacyPolicyWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
privacyPolicyWebView.setWebViewClient(new WebViewClient() { });
privacyPolicyWebView.resumeTimers();
privacyPolicyWebView.loadUrl("http://www.soasta.com/privacy-policy");
}
示例7: preSetting
import android.webkit.WebSettings; //導入依賴的package包/類
private void preSetting(){
//加載服務器上的頁麵
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBlockNetworkImage(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(
WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
}
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view,
SslErrorHandler handler, SslError error) {
// TODO Auto-generated method stub
// handler.cancel();// Android默認的處理方式
handler.proceed();// 接受所有網站的證書
// handleMessage(Message msg);// 進行其他處理
}
});
//加載本地中的html
//myWebView.loadUrl("file:///android_asset/www/test2.html");
//加上下麵這段代碼可以使網頁中的鏈接不以瀏覽器的方式打開
mWebView.setWebViewClient(new WebViewClient());
//允許使用javascript
mWebView.getSettings().setJavaScriptEnabled(true);
}
示例8: initWebViewSettings
import android.webkit.WebSettings; //導入依賴的package包/類
/**
* @param webView
*/
@SuppressLint("SetJavaScriptEnabled")
public static void initWebViewSettings(WebView webView) {
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setDefaultFontSize(15);
//設置緩存
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setAppCacheEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setAppCachePath(AppConfig.WEB_CACHE_PATH);
}
示例9: loadData
import android.webkit.WebSettings; //導入依賴的package包/類
private void loadData() {
Picasso.with(this).load(getIntent("thumbnail")).into(imgCover);
txtWriter.setText(getIntent("writer"));
txtDate.setText(getIntent("date"));
webViewContent.setScrollContainer(false);
webViewContent.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webViewContent.loadData(WebViewContent.clean(getContent()), "text/html; charset=utf-8", "utf-8");
}
示例10: onCreate
import android.webkit.WebSettings; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
getSupportActionBar().setTitle(getString(R.string.about));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.getIndeterminateDrawable()
.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
info_web = (WebView) findViewById(R.id.webview_company_info);
info_web.setBackgroundColor(Color.TRANSPARENT);
info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
info_web.setWebViewClient(new myWebClient());
info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
info_web.getSettings().setJavaScriptEnabled(true);
String infoText = getString(R.string.company_info_web);
info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);
}
示例11: onCreate
import android.webkit.WebSettings; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
WebSettings settings = webView.getSettings();
settings.setAllowFileAccessFromFileURLs(true);
settings.setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JavascriptHandler(this, webView), "JavascriptHandler");
webView.loadUrl("file:///android_asset/Sample.framer/index.html");
}
示例12: loadImage
import android.webkit.WebSettings; //導入依賴的package包/類
public void loadImage(@NonNull String url, boolean isSvg) {
WebSettings settings = getSettings();
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
String html;
if (isSvg) {
html = url;
} else {
html = "<html><head><style>img{display: inline; height: auto; max-width: 100%;}</style></head><body>" +
"<img src=\"" + url + "\"/></body></html>";
}
Logger.e(html);
loadData(html, "text/html", null);
}
示例13: initView
import android.webkit.WebSettings; //導入依賴的package包/類
@Override
public void initView() {
mIbToolbarMore.setVisibility(View.VISIBLE);
//設置webView
WebSettings settings = mWebView.getSettings();
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumLogicalFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(WebSettings.TextSize.NORMAL);
mWebView.setVerticalScrollbarOverlay(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl(mUrl);
setToolbarTitle(TextUtils.isEmpty(mTitle) ? mWebView.getTitle() : mTitle);
}
示例14: initViews
import android.webkit.WebSettings; //導入依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initViews() {
setTitle(getIntent().getStringExtra(EXTRA_TITLE));
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setAppCacheEnabled(true);
settings.setSupportZoom(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mUrl = getIntent().getStringExtra(EXTRA_URL);
mWebView.loadUrl(mUrl);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
}
示例15: a
import android.webkit.WebSettings; //導入依賴的package包/類
protected RegisterView a() {
RegisterView registerView = new RegisterView(this.activity);
registerView.c().getChildAt(registerView.c().getChildCount() - 1).setVisibility(8);
registerView.a().setOnClickListener(new j(this));
this.e = registerView.b();
WebSettings settings = this.e.getSettings();
settings.setBuiltInZoomControls(true);
settings.setJavaScriptEnabled(true);
settings.setCacheMode(1);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDatabasePath(this.activity.getDir("database", 0).getPath());
this.e.setVerticalScrollBarEnabled(false);
this.e.setHorizontalScrollBarEnabled(false);
this.e.setWebViewClient(new l(this));
return registerView;
}