当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings.setJavaScriptEnabled方法代码示例

本文整理汇总了Java中android.webkit.WebSettings.setJavaScriptEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setJavaScriptEnabled方法的具体用法?Java WebSettings.setJavaScriptEnabled怎么用?Java WebSettings.setJavaScriptEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setJavaScriptEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
private void init() {
    setClickable(false);
    setFocusable(false);

    setHorizontalScrollBarEnabled(false);

    WebSettings settings = getSettings();
    settings.setDefaultFontSize(14);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    settings.setDisplayZoomControls(false);
    settings.setJavaScriptEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        addJavascriptInterface(new OnWebViewImageListener() {
            @Override
            @JavascriptInterface
            public void showImagePreview(String bigImageUrl) {
                if (bigImageUrl != null && !StringUtils.isEmpty(bigImageUrl)) {
                    ImageGalleryActivity.show(getContext(), bigImageUrl);
                }
            }
        }, "mWebViewImageListener");
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:27,代码来源:OWebView.java

示例2: writeEncryToken

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled"})
public void writeEncryToken(Context context) {
    String str = "tencent&sdk&qazxc***14969%%";
    String accessToken = this.mToken.getAccessToken();
    String appId = this.mToken.getAppId();
    String openId = this.mToken.getOpenId();
    String str2 = "qzone3.4";
    if (accessToken == null || accessToken.length() <= 0 || appId == null || appId.length() <= 0 || openId == null || openId.length() <= 0) {
        str = null;
    } else {
        str = Util.encrypt(str + accessToken + appId + openId + str2);
    }
    com.tencent.open.c.b bVar = new com.tencent.open.c.b(context);
    WebSettings settings = bVar.getSettings();
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptEnabled(true);
    settings.setDatabaseEnabled(true);
    accessToken = "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\"><title>localStorage Test</title><script type=\"text/javascript\">document.domain = 'qq.com';localStorage[\"" + this.mToken.getOpenId() + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + this.mToken.getAppId() + "\"]=\"" + str + "\";</script></head><body></body></html>";
    str = ServerSetting.getInstance().getEnvUrl(context, ServerSetting.DEFAULT_LOCAL_STORAGE_URI);
    bVar.loadDataWithBaseURL(str, accessToken, "text/html", "utf-8", str);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:SocialApiIml.java

示例3: onCreate

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //初始化两个栈的数据结构
    backStack = new Stack<URL>();
    forwardStack = new Stack<URL>();
    //获取两个按钮实例
    backButton = (Button)findViewById(R.id.backButton);
    forwardButton = (Button) findViewById(R.id.forwardButton);
    //获取输入框实例
    editor = (EditText) findViewById(R.id.url);
    //获取显示区域实例
    stage = (WebView) findViewById(R.id.content);
    WebSettings settings = stage.getSettings();
    settings.setJavaScriptEnabled(true);
    stage.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    client = new Client(backStack,editor);
    stage.setWebViewClient(client);
    //初始化,设置主页为www.smxy.cn
    stage.loadUrl("http://www.smxy.cn");
   // currentURL = "http://www.smxy.cn";
    //editor.setText(currentURL);


}
 
开发者ID:mgsky1,项目名称:WebStackDemo,代码行数:27,代码来源:MainActivity.java

示例4: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView(String url) {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDisplayZoomControls(false);
    if (Build.VERSION.SDK_INT >= 21) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.loadUrl(url);
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:22,代码来源:WebActivity.java

示例5: onCreate

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);

	resultCode = RESULT_OK;
	setContentView(R.layout.print_dialog);
	dialogWebView = (WebView) findViewById(R.id.webview);
	cloudPrintIntent = this.getIntent();

	WebSettings settings = dialogWebView.getSettings();
	settings.setJavaScriptEnabled(true);

	dialogWebView.setWebViewClient(new PrintDialogWebClient());
	dialogWebView.addJavascriptInterface(
		new PrintDialogJavaScriptInterface(), JS_INTERFACE);

	dialogWebView.loadUrl(PRINT_DIALOG_URL);
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-old,代码行数:19,代码来源:PrintDialogActivity.java

示例6: SourceEditor

import android.webkit.WebSettings; //导入方法依赖的package包/类
/**
 * Create source editor using given web view
 *
 * @param view
 */
@SuppressLint("AddJavascriptInterface")
public SourceEditor(final WebView view) {
    WebSettings settings = view.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    try {
        int version = Build.VERSION.SDK_INT;
        if (version >= 11) {
            // 这个方法在API level 11 以上才可以调用,不然会发生异常
            settings.setDisplayZoomControls(false);
        }
    } catch (NumberFormatException e) {

    }
    settings.setUseWideViewPort(true);
    view.addJavascriptInterface(SourceEditor.this, "SourceEditor");
    this.view = view;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:24,代码来源:SourceEditor.java

示例7: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled", "AddJavascriptInterface"})
private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccess(true);
    mWebView.addJavascriptInterface(new JsInterface(this), "imgClickListener");
    mWebView.addJavascriptInterface(new JsInterface(this), "comjs");
    mWebView.setWebViewClient(new BaseWebViewClient());
}
 
开发者ID:shenhuanet,项目名称:ZhidaoDaily-android,代码行数:10,代码来源:DetailActivity.java

示例8: onCreateView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view= inflater.inflate(R.layout.fragment_educator, container, false);
    web=(WebView)view.findViewById(R.id.web_View);
    WebSettings webs =web.getSettings();
    webs.setJavaScriptEnabled(true);
    web.loadUrl(myUrl);
    web.setWebViewClient(new myWebViewClient());
    return view;
}
 
开发者ID:IOSD,项目名称:YFHR_Android_App,代码行数:13,代码来源:educator.java

示例9: initWeb

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWeb() {
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    mWebView.loadUrl("file:///android_asset/speedtest.html");
    mWebView.setWebViewClient(new WebViewClient());
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:12,代码来源:SpeedTestActivity.java

示例10: destroy

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void destroy() {
    setWebViewClient(null);

    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(false);

    removeAllViewsInLayout();

    removeAllViews();
    super.destroy();
}
 
开发者ID:bigjelly,项目名称:ShaddockVideoPlayer,代码行数:13,代码来源:NWebView.java

示例11: AccountCreationWebview

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public AccountCreationWebview(BasePrefsWizard aParent, String url, OnAccountCreationDoneListener l){
    parent = aParent;
    creationListener = l;
    webCreationPage = url;
    
    settingsContainer = (ViewGroup) parent.findViewById(R.id.settings_container);
    validationBar = (ViewGroup) parent.findViewById(R.id.validation_bar);
    
    ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent();
    
    parent.getLayoutInflater().inflate(R.layout.wizard_account_creation_webview, globalContainer);
    
    webView = (WebView) globalContainer.findViewById(R.id.webview);
    loadingProgressBar = (ProgressBar) globalContainer.findViewById(R.id.webview_progress);
    
    WebSettings webSettings = webView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(false);
    webSettings.setCacheMode(WebSettings.LOAD_NORMAL);
    webSettings.setNeedInitialFocus(true);
    webView.addJavascriptInterface(new JSInterface(), "CSipSimpleWizard");
    
    // Adds Progress bar Support
    webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if(progress < 100) {
                loadingProgressBar.setVisibility(View.VISIBLE);
                loadingProgressBar.setProgress(progress); 
            }else {
                loadingProgressBar.setVisibility(View.GONE);
            }
        }
    });
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:38,代码来源:AccountCreationWebview.java

示例12: MarkdownView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
public MarkdownView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (isInEditMode()) {
        return;
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    initialize();
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:13,代码来源:MarkdownView.java

示例13: initData

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initData() {
    WebSettings settings = logisticsWebView.getSettings();
    settings.setJavaScriptEnabled(true);//开启webview支持JS
    settings.setDatabaseEnabled(true);
    String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();

    //启用地理定位
    settings.setGeolocationEnabled(true);
    //设置定位的数据库路径
    settings.setGeolocationDatabasePath(dir);
    settings.setDomStorageEnabled(true);

    settings.setCacheMode(LOAD_NO_CACHE);
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:15,代码来源:LogisticsWebActivity.java

示例14: WebViewTask

import android.webkit.WebSettings; //导入方法依赖的package包/类
public WebViewTask(Context context) {
    webView = new WebView(context);
    webView.addJavascriptInterface(new InJavaScriptLocalObj(), "get_source");
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            webView.loadUrl("javascript:window.get_source.getSource('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
        }
    });
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setBlockNetworkImage(true);
    webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36");
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:16,代码来源:WebViewTask.java

示例15: onCreate

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_web);
    name = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_NAME);
    url = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_URL);
    color = getIntent().getExtras().getInt(Common.WEBVIEW_EXTRA_COLOR);
    needsLogin = getIntent().getExtras().getBoolean(Common.WEBVIEW_EXTRA_NLOGIN);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(color);
        getWindow().setStatusBarColor(color);
    }
    app = (App) getApplication();

    TextView title = (TextView) findViewById(R.id.toolbar_title);
    title.setText(name);

    progress = (ProgressBar) findViewById(R.id.web_progressBar);
    webView = (WebView) findViewById(R.id.webView);

    if (savedInstanceState != null) {
        progress.setVisibility(View.INVISIBLE);
        webView.setVisibility(View.VISIBLE);
        webView.restoreState(savedInstanceState);
    }
    else {
        progress.setVisibility(View.VISIBLE);
        webView.setWebViewClient(new WebViewClient());
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUserAgentString("IEMobile");
        startControllers();
    }

}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:41,代码来源:WebActivity.java


注:本文中的android.webkit.WebSettings.setJavaScriptEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。