當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。