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


Java WebViewClient类代码示例

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


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

示例1: onCreate

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_webview);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final Item item = (Item) getIntent().getSerializableExtra("item");

    WebView webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    setContentView(webView);
    webView.loadUrl(item.getUrl());
}
 
开发者ID:dandanes7,项目名称:lurkerhn,代码行数:22,代码来源:StoryWebViewActivity.java

示例2: QuotedMessageMvpView

import android.webkit.WebViewClient; //导入依赖的package包/类
public QuotedMessageMvpView(MessageCompose messageCompose) {
    mQuotedTextShow = (Button) messageCompose.findViewById(R.id.quoted_text_show);
    mQuotedTextBar = messageCompose.findViewById(R.id.quoted_text_bar);
    mQuotedTextEdit = (ImageButton) messageCompose.findViewById(R.id.quoted_text_edit);
    mQuotedTextDelete = (ImageButton) messageCompose.findViewById(R.id.quoted_text_delete);
    mQuotedText = (EolConvertingEditText) messageCompose.findViewById(R.id.quoted_text);
    mQuotedText.getInputExtras(true).putBoolean("allowEmoji", true);

    mQuotedHTML = (MessageWebView) messageCompose.findViewById(R.id.quoted_html);
    mQuotedHTML.configure();
    // Disable the ability to click links in the quoted HTML page. I think this is a nice feature, but if someone
    // feels this should be a preference (or should go away all together), I'm ok with that too. -achen 20101130
    mQuotedHTML.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }
    });

    mMessageContentView = (EolConvertingEditText) messageCompose.findViewById(R.id.message_content);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:QuotedMessageMvpView.java

示例3: setWebView

import android.webkit.WebViewClient; //导入依赖的package包/类
private void setWebView()
{

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);//如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
    webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
    webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
    webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
    webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
    webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件
    webSettings.setAllowFileAccess(true); //设置可以访问文件
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
    webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
    webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式
    webSettings.setDomStorageEnabled(true);
    mWebView.setWebViewClient(new WebViewClient());
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:18,代码来源:WebViewFragment.java

示例4: createWebViewClient

import android.webkit.WebViewClient; //导入依赖的package包/类
private WebViewClient createWebViewClient() {
    return new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains(TimeLinePatterns.WEB_SCHEME) || url.contains("https://")) {
                view.loadUrl(url);
            } else if (!BooheeScheme.handleUrl(HardwareIntroActivity.this, url)) {
                Uri uri = Uri.parse(url);
                if (uri != null) {
                    Intent intent = new Intent();
                    intent.setAction("android.intent.action.VIEW");
                    intent.setData(uri);
                    HardwareIntroActivity.this.startActivity(intent);
                }
            }
            return true;
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:HardwareIntroActivity.java

示例5: onCreateView

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v  = inflater.inflate(R.layout.layout_web, container, false);
    WebView w = (WebView) v.findViewById(R.id.webView);
    w.loadUrl("http://p.codekk.com/");
    w.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    return v;
}
 
开发者ID:zhouphenix,项目名称:Multi-SwipeToRefreshLayout,代码行数:17,代码来源:WebViewFragment.java

示例6: onCreate

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reg);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    actionBar=getSupportActionBar();
    actionBar.setTitle("Register");

    Bundle bundle=this.getIntent().getExtras();
    url=bundle.getString("url");
    webView = (WebView)findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(url);

}
 
开发者ID:vikasdesale,项目名称:Wings2K16,代码行数:18,代码来源:RegisterActivity.java

示例7: onCreate

import android.webkit.WebViewClient; //导入依赖的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");
}
 
开发者ID:SOASTA,项目名称:touchtestweb-android,代码行数:17,代码来源:PrivacyPolicyActivity.java

示例8: load

import android.webkit.WebViewClient; //导入依赖的package包/类
public void load(final String fileName) {

        // Set WebView client
        WebViewClient loadFinishedClient = new WebViewClient() {

            public void onPageFinished(WebView view, String url) {

                // Set platform to android
                JSONObject evt = new JSONObject();
                try {
                    evt.put("name", "android");
                } catch (JSONException e) {
                    WonderLog.logError(e);
                }
                initPlatformSetting(evt.toString());
            }
        };

        setWebViewClient(loadFinishedClient);

        // Load content from URL
        loadUrl(fileName);
    }
 
开发者ID:prophecy,项目名称:WonderWebOnNative,代码行数:24,代码来源:WonderWebView.java

示例9: onCreate

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    wv_test = (WebView)findViewById(R.id.wv_test) ;
    wv_test.getSettings().setJavaScriptEnabled(true);
    /* "JSInterface" ==> window.JSInterface
     * class JSInterface all @javascriptInterface methods
     * js can call JSInterface.method()*/
    wv_test.addJavascriptInterface(new JSInterface(MainActivity.this),"JSInterface");
    /* at webivew not brower*/
    wv_test.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            return true ;
        }
    });
    wv_test.loadUrl("file:///android_asset/JSInterface.html");
    //wv_test.loadUrl("http://127.0.0.1:8080/JSInterface.html");
}
 
开发者ID:HuChengSheng,项目名称:JSInterface,代码行数:21,代码来源:MainActivity.java

示例10: initWebView

import android.webkit.WebViewClient; //导入依赖的package包/类
@SuppressLint("JavascriptInterface")
private void initWebView() {
    mDetailWebView.getSettings().setJavaScriptEnabled(true);


    mDetailWebView.addJavascriptInterface(mPresenter, "web");

    mDetailWebView.setWebViewClient(new WebViewClient() {
        //返回值为true	表示网页点击新的链接操作让我们自己处理
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
}
 
开发者ID:Jay-Ping,项目名称:newIPlay,代码行数:17,代码来源:DetailActivity.java

示例11: onReceivedError

import android.webkit.WebViewClient; //导入依赖的package包/类
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
开发者ID:fachrihawari,项目名称:cordova-vuetify,代码行数:33,代码来源:SystemWebViewClient.java

示例12: onCreate

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_eula);

    toolBarView = (ToolBarView) findViewById(R.id.eula_toolbar);
    webView = (WebView) findViewById(R.id.eula_webview);

    toolBarView.setTitleText("用户服务条款和隐私协议");
    toolBarView.setBackButtonImage(R.mipmap.icon_back);
    toolBarView.setBackButtonVisible(true);
    toolBarView.setBackButtonOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(ServerUtil.WVAgreement);

}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:24,代码来源:EULAActivity.java

示例13: initWebView

import android.webkit.WebViewClient; //导入依赖的package包/类
private void initWebView() {
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                if (contentLayout != null)
                    contentLayout.showContent();
                if (webView != null)
                    url = webView.getUrl();
            } else {
                if (contentLayout != null)
                    contentLayout.showLoading();
            }
        }
    });
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);

    webView.loadUrl(url);
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:27,代码来源:WebActivity.java

示例14: initView

import android.webkit.WebViewClient; //导入依赖的package包/类
@Override
protected void initView() {

    String name = getIntent().getStringExtra("name");
    String url = getIntent().getStringExtra("url");

    //设置沉浸式状态栏
    setStatus();
    iv_search.setVisibility(View.VISIBLE);
    //设置沉浸式状态栏背景
    bar_layout.setBackgroundResource(R.color.black_alpha_5);

    title_text.setText(name);

    wv.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            super.onReceivedSslError(view, handler, error);
            handler.proceed();
        }
    });
    wv.getSettings().setJavaScriptEnabled(true);

    wv.loadUrl(url);
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:26,代码来源:WebViewActivity.java

示例15: getClient

import android.webkit.WebViewClient; //导入依赖的package包/类
@Deprecated
private WebViewClient getClient() {

    if (!webClientHelper && AgentWebConfig.WEBVIEW_TYPE != AgentWebConfig.WEBVIEW_AGENTWEB_SAFE_TYPE && mWebViewClient != null) {
        return mWebViewClient;
    } else {
        LogUtils.i(TAG, "isInterceptUnkownScheme:" + isInterceptUnkownScheme + "   openOtherAppWays:" + openOtherAppWays);
        return DefaultWebClient
                .createBuilder()
                .setActivity(this.mActivity)
                .setClient(this.mWebViewClient)
                .setManager(this.mWebViewClientCallbackManager)
                .setWebClientHelper(this.webClientHelper)
                .setPermissionInterceptor(this.mPermissionInterceptor)
                .setWebView(this.mWebCreator.get())
                .setInterceptUnkownScheme(this.isInterceptUnkownScheme)
                .setSchemeHandleType(this.openOtherAppWays)
                .setCfg(this.mDefaultMsgConfig.getWebViewClientMsgCfg())
                .build();
    }


}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:24,代码来源:AgentWeb.java


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