本文整理汇总了Java中android.webkit.WebSettings.setPluginState方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setPluginState方法的具体用法?Java WebSettings.setPluginState怎么用?Java WebSettings.setPluginState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setPluginState方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWidgets
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
super.initWidgets();
mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
mBackImg.setOnClickListener(this);
mWebView = (WebView) findViewById(R.id.kf5_post_detail_content);
mDetailTitle = (TextView) findViewById(R.id.kf5_post_detail_title);
mDate = (TextView) findViewById(R.id.kf5_post_detail_date);
WebSettings webSettings = mWebView.getSettings();
webSettings.setBuiltInZoomControls(false);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setBuiltInZoomControls(false); //显示放大缩小 controler
webSettings.setSupportZoom(false); //可以缩放
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mWebView.setWebViewClient(new MyWebViewClient());
}
示例2: setWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setWebView() {
WebSettings ws = wvNewContent.getSettings();
ws.setJavaScriptEnabled(true); //支持js
ws.setPluginState(WebSettings.PluginState.ON);//设置是否支持插件
ws.setUseWideViewPort(false); //将图片调整到适合webview的大小
ws.setSupportZoom(true); //支持缩放
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
ws.supportMultipleWindows(); //多窗口
ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
// cache模式有如下几种:
// LOAD_DEFAULT: 如果我们应用程序没有设置任何cachemode, 这个是默认的cache方式。 加载一张网页会检查是否有cache,如果有并且没有过期则使用本地cache,否则从网络上获取。
// LOAD_CACHE_ELSE_NETWORK: 使用cache资源,即使过期了也使用,如果没有cache才从网络上获取。
// LOAD_NO_CACHE: 不使用cache 全部从网络上获取
// LOAD_CACHE_ONLY: 只使用cache上的内容
ws.setAllowFileAccess(true); //设置可以访问文件
ws.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
ws.setBuiltInZoomControls(true); //设置支持缩放
ws.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
ws.setLoadsImagesAutomatically(true); //支持自动加载图片
}
示例3: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void init(Context context) {
this.setVerticalScrollBarEnabled(false);
this.setHorizontalScrollBarEnabled(false);
if (Build.VERSION.SDK_INT < 19) {
removeJavascriptInterface("searchBoxJavaBridge_");
}
WebSettings localWebSettings = this.getSettings();
try {
// 禁用file协议,http://www.tuicool.com/articles/Q36ZfuF, 防止Android WebView File域攻击
localWebSettings.setAllowFileAccess(false);
localWebSettings.setSupportZoom(false);
localWebSettings.setBuiltInZoomControls(false);
localWebSettings.setUseWideViewPort(true);
localWebSettings.setDomStorageEnabled(true);
localWebSettings.setLoadWithOverviewMode(true);
localWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
localWebSettings.setPluginState(PluginState.ON);
// 启用数据库
localWebSettings.setDatabaseEnabled(true);
// 设置定位的数据库路径
String dir = context.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
localWebSettings.setGeolocationDatabasePath(dir);
localWebSettings.setGeolocationEnabled(true);
localWebSettings.setJavaScriptEnabled(true);
localWebSettings.setSavePassword(false);
String agent = localWebSettings.getUserAgentString();
localWebSettings.setUserAgentString(agent);
// setCookie(context, ".baidu.com", bdussCookie);
} catch (Exception e1) {
e1.printStackTrace();
}
this.setWebViewClient(new BridgeWebViewClient());
}
示例4: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_noticia);
//Pega a notícia passada pela ActivityPrincipal
mNoticia = (Noticia)getIntent().getExtras().get("noticia");
//Obtem da View
mToolbar = (Toolbar) findViewById(R.id.tb_noticias);
mToolbar.setTitle(mNoticia.getTitulo());
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
//Obtem da View
mImageView = (ImageView) findViewById(R.id.iv_noticias);
//Carrega a imagem com a biblioteca Picasso
Picasso.with(this).load(Uri.parse(Utils.getUrlApiThumbnail(this).replace("$tipo", "noticias").replace("$id", String.valueOf(mNoticia.getId()))+"&thumb=false")).placeholder(R.drawable.no_avatar).into(mImageView);
//Obtem da View
mWebView = (WebView) findViewById(R.id.web_noticias);
//Carrega o conteúdo
mWebView.loadDataWithBaseURL("file:///android_asset/","<link rel=\"stylesheet\" type=\"text/css\" href=\"estilo.css\" />"+mNoticia.getConteudo(),"text/html", "UTF-8", null);
//Permite Javascript e outros fatores
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAllowContentAccess(true);
WebSettings webSettings = mWebView.getSettings();
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setUseWideViewPort(true);
mWebView.setWebChromeClient(new WebChromeClient() {});
}
示例5: configWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void configWebView() {
mWebView = new WebView(getApplicationContext());
mWebViewContainer.addView(mWebView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDefaultTextEncodingName("UTF-8");
settings.setSupportZoom(false);
settings.setPluginState(WebSettings.PluginState.ON);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
示例6: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
/**
* 初始化浏览器设置信息
*/
private void initWebView() {
cookie = CookieManager.getInstance();
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true); // 启用支持javascript
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);// 优先使用缓存
webSettings.setAllowFileAccess(true);// 可以访问文件
webSettings.setBuiltInZoomControls(true);// 支持缩放
if (android.os.Build.VERSION.SDK_INT >= 11) {
webSettings.setPluginState(PluginState.ON);
webSettings.setDisplayZoomControls(false);// 支持缩放
}
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(new MyWebChromeClient());
}
示例7: initWebSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebSettings() {
WebSettings settings = mWebView.getSettings();
//支持获取手势焦点
mWebView.requestFocusFromTouch();
//支持JS
settings.setJavaScriptEnabled(true);
//支持插件
settings.setPluginState(WebSettings.PluginState.ON);
//设置适应屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
//支持缩放
settings.setSupportZoom(false);
//隐藏原生的缩放控件
settings.setDisplayZoomControls(false);
//支持内容重新布局
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.supportMultipleWindows();
settings.setSupportMultipleWindows(true);
//设置缓存模式
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setAppCacheEnabled(true);
settings.setAppCachePath(mWebView.getContext().getCacheDir().getAbsolutePath());
//设置可访问文件
settings.setAllowFileAccess(true);
//当webview调用requestFocus时为webview设置节点
settings.setNeedInitialFocus(true);
//支持自动加载图片
if (Build.VERSION.SDK_INT >= 19) {
settings.setLoadsImagesAutomatically(true);
} else {
settings.setLoadsImagesAutomatically(false);
}
settings.setNeedInitialFocus(true);
//设置编码格式
settings.setDefaultTextEncodingName("UTF-8");
}
示例8: initSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initSettings() {
WebSettings webSettings = mDXHWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= 16) {
webSettings.setAllowFileAccessFromFileURLs(true);
}
webSettings.setDomStorageEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
if (NetworkUtils.isConnected(mContext) ){
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
} else {
webSettings.setCacheMode(
WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
webSettings.setDatabaseEnabled(true);
webSettings.setAppCacheMaxSize(1024 * 1024 * 8);
webSettings.setAppCacheEnabled(true);
//File fDatabase = new File(mContext.getCacheDir().getAbsolutePath(),"webview_db");
//webSettings.setDatabasePath(fDatabase.getAbsolutePath());
File fAppCache = new File(mContext.getCacheDir().getAbsolutePath(),"webview_cache");
webSettings.setAppCachePath(fAppCache.getAbsolutePath());
webSettings.setBuiltInZoomControls(true);// api-3
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
if (Build.VERSION.SDK_INT >= 11) {
webSettings.setDisplayZoomControls(false);// api-11
}
//http://wiki.jikexueyuan.com/project/chrome-devtools/remote-debugging-on-android.html
if (Build.VERSION.SDK_INT >= 19) {//for chrome debug
WebView.setWebContentsDebuggingEnabled(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(
WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
}
}
示例9: b
import android.webkit.WebSettings; //导入方法依赖的package包/类
private boolean b() {
this.b = (WebView) this.d.findViewById(ResContainer.getResourceId(this.k, ResType.ID,
"webView"));
this.b.setWebViewClient(c());
this.b.setWebChromeClient(new p(this));
this.b.requestFocusFromTouch();
this.b.setVerticalScrollBarEnabled(false);
this.b.setHorizontalScrollBarEnabled(false);
this.b.setScrollBarStyle(0);
this.b.getSettings().setCacheMode(2);
WebSettings settings = this.b.getSettings();
settings.setJavaScriptEnabled(true);
if (VERSION.SDK_INT >= 8) {
settings.setPluginState(PluginState.ON);
}
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setAllowFileAccess(true);
settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
settings.setUseWideViewPort(true);
if (VERSION.SDK_INT >= 8) {
settings.setLoadWithOverviewMode(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
settings.setGeolocationEnabled(true);
settings.setAppCacheEnabled(true);
}
if (VERSION.SDK_INT >= 11) {
try {
Method declaredMethod = WebSettings.class.getDeclaredMethod
("setDisplayZoomControls", new Class[]{Boolean.TYPE});
declaredMethod.setAccessible(true);
declaredMethod.invoke(settings, new Object[]{Boolean.valueOf(false)});
} catch (Exception e) {
}
}
try {
if (this.m == SHARE_MEDIA.RENREN) {
CookieSyncManager.createInstance(this.k);
CookieManager.getInstance().removeAllCookie();
}
} catch (Exception e2) {
}
return true;
}