Search in sources :

Example 61 with WebViewClient

use of android.webkit.WebViewClient in project mintube by imshyam.

the class WebPlayer method setupPlayer.

public void setupPlayer() {
    player.getSettings().setJavaScriptEnabled(true);
    // For debugging using chrome on PC
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        player.setWebContentsDebuggingEnabled(true);
    }
    player.setWebChromeClient(new WebChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        player.getSettings().setMediaPlaybackRequiresUserGesture(false);
    }
    player.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:21.0.0) Gecko/20121011 Firefox/21.0.0");
    // ----------------------------To get Player Id-------------------------------------------
    player.addJavascriptInterface(new JavaScriptInterface((PlayerService) context), "Interface");
    player.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            PlayerService.addStateChangeListener();
        }
    });
}
Also used : WebChromeClient(android.webkit.WebChromeClient) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 62 with WebViewClient

use of android.webkit.WebViewClient in project Stringlate by LonamiWebs.

the class BrowserActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_online_help);
    webview = findViewById(R.id.webview);
    WebSettings webSettings = webview.getSettings();
    webSettings.setAllowFileAccess(false);
    webSettings.setUserAgentString("Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
    webview.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    Intent intent = getIntent();
    if (isShowingStringlateHelp = intent.getBooleanExtra(EXTRA_DO_SHOW_STRINGLATE_HELP, false)) {
        webSettings.setAllowFileAccess(true);
        String locale = Locale.getDefault().getLanguage();
        if (!helpAvailableForLocale(locale))
            locale = ONLINE_HELP_DEFAULT_LOCALE;
        webview.loadUrl(String.format("file:///android_res/raw/%s.html", locale));
    }
    if (!TextUtils.isEmpty(intent.getStringExtra(EXTRA_LOAD_URL))) {
        webview.loadUrl(intent.getStringExtra(EXTRA_LOAD_URL));
    }
}
Also used : WebSettings(android.webkit.WebSettings) Intent(android.content.Intent) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 63 with WebViewClient

use of android.webkit.WebViewClient in project guanggoo-android by mzlogin.

the class TopicDetailFragment method initWebView.

private void initWebView() {
    mContentWebView.getSettings().setUseWideViewPort(false);
    mContentWebView.getSettings().setLoadWithOverviewMode(true);
    mContentWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
    mContentWebView.setWebChromeClient(new WebChromeClient());
    mContentWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            FragmentFactory.PageType pageType = FragmentFactory.getPageTypeByUrl(url);
            if (mListener != null && pageType == FragmentFactory.PageType.VIEW_IMAGE) {
                mListener.openPage(url, getString(R.string.view_image));
                return true;
            }
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        }
    });
    mContentWebView.getSettings().setJavaScriptEnabled(true);
}
Also used : WebChromeClient(android.webkit.WebChromeClient) Intent(android.content.Intent) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 64 with WebViewClient

use of android.webkit.WebViewClient in project vialer-android by VoIPGRID.

the class WebActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);
    // Set the Toolbar to use as ActionBar
    setSupportActionBar((Toolbar) findViewById(R.id.action_bar));
    // Set the Toolbar title
    getSupportActionBar().setTitle(getIntent().getStringExtra(TITLE));
    // Enabled home as up for the Toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Enabled home button for the Toolbar
    getSupportActionBar().setHomeButtonEnabled(true);
    // Get the ProgressBar
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    // Get the WebView.
    mWebView = (WebView) findViewById(R.id.web_view);
    // Enable javascript.
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    // Set webview client.
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url) {
            webView.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            mProgressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            mProgressBar.setVisibility(View.INVISIBLE);
            if (getIntent().getStringExtra(PAGE).equals(getString(R.string.web_password_change))) {
                final String js = "javascript:document.getElementById('id_username').value='" + getIntent().getStringExtra(USERNAME) + "';" + "document.getElementById('id_password').value='" + getIntent().getStringExtra(PASSWORD) + "';" + "document.forms[0].submit();";
                if (Build.VERSION.SDK_INT >= 19) {
                    view.evaluateJavascript(js, new ValueCallback<String>() {

                        @Override
                        public void onReceiveValue(String s) {
                        }
                    });
                } else {
                    view.loadUrl(js);
                }
            }
        }
    });
    String uri = getIntent().getStringExtra(PAGE);
    if (uri.startsWith("http")) {
        loadPage(uri);
    } else {
        // request an autologin token and load the requested page.
        autoLoginToken();
    }
    // Track the web view.
    AnalyticsHelper analyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    analyticsHelper.sendScreenViewTrack(getIntent().getStringExtra(GA_TITLE));
}
Also used : ValueCallback(android.webkit.ValueCallback) Bitmap(android.graphics.Bitmap) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 65 with WebViewClient

use of android.webkit.WebViewClient in project Tools-For-Android-Development by hatanvir.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    webView = findViewById(R.id.WebViewIdXml);
    webView.loadUrl("http://www.primeasia.edu.bd/");
    // javascript enable
    WebSettings webSettings = webView.getSettings();
    webSettings.getJavaScriptEnabled();
    // for visiting more page
    webView.setWebViewClient(new WebViewClient());
}
Also used : WebSettings(android.webkit.WebSettings) WebViewClient(android.webkit.WebViewClient)

Aggregations

WebViewClient (android.webkit.WebViewClient)247 WebView (android.webkit.WebView)229 WebSettings (android.webkit.WebSettings)77 View (android.view.View)71 WebChromeClient (android.webkit.WebChromeClient)69 SuppressLint (android.annotation.SuppressLint)61 Intent (android.content.Intent)60 Bitmap (android.graphics.Bitmap)59 WebResourceRequest (android.webkit.WebResourceRequest)35 TextView (android.widget.TextView)26 LinearLayout (android.widget.LinearLayout)22 WebResourceError (android.webkit.WebResourceError)21 WebResourceResponse (android.webkit.WebResourceResponse)16 Uri (android.net.Uri)15 SslError (android.net.http.SslError)13 Bundle (android.os.Bundle)13 Toolbar (android.support.v7.widget.Toolbar)13 KeyEvent (android.view.KeyEvent)13 SslErrorHandler (android.webkit.SslErrorHandler)13 TargetApi (android.annotation.TargetApi)12