Example usage for android.webkit WebViewClient WebViewClient

List of usage examples for android.webkit WebViewClient WebViewClient

Introduction

In this page you can find the example usage for android.webkit WebViewClient WebViewClient.

Prototype

WebViewClient

Source Link

Usage

From source file:com.toan_itc.tn.Fragment.WebviewFragment.java

@Nullable
@Override//from   www .  j  a va 2 s.com
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_details, container, false);
    webView = (WebView) view.findViewById(R.id.webview);
    String url = getArguments().getString(EXTRA_URL);
    Log.wtf("url=", url);
    webView.setWebViewClient(new WebViewClient());
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl(url);
    return view;
}

From source file:it.gaiacri.mobile.AboutAttivita.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout v = (LinearLayout) inflater.inflate(R.layout.activity_about, container, false);

    ((TextView) v.findViewById(R.id.about_title)).setText("Gaia Mobile v " + getString(R.string.app_version));

    GaiaGoogleAnalytics.notifyScreen(getActivity().getApplicationContext(), "About");

    //licenza//from w  w  w  .j  a v  a2s . com
    ((TextView) v.findViewById(R.id.about_licenza))
            .setText(Html.fromHtml("Questa applicazione  rilasciata con licenza <a href=\"\">GPL v3</a>"));
    ((TextView) v.findViewById(R.id.about_licenza)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            AlertDialog.Builder alert = new AlertDialog.Builder(AboutAttivita.this.getActivity());
            WebView wv = new WebView(AboutAttivita.this.getActivity());
            wv.loadUrl("https://raw.githubusercontent.com/CroceRossaItaliana/gaia-android/master/LICENSE.txt");
            wv.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);

                    return true;
                }
            });
            alert.setView(wv);
            alert.setNegativeButton("Chiudi", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });
            alert.show();
        }
    });
    //portale gaia
    ((TextView) v.findViewById(R.id.about_portale_gaia))
            .setText(Html.fromHtml("<a href=\"\">Portale Gaia</a>"));
    ((TextView) v.findViewById(R.id.about_portale_gaia)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Internet("https://gaia.cri.it");
        }
    });
    //informazioni gaia
    ((TextView) v.findViewById(R.id.about_gaia)).setText(Html.fromHtml("<a href=\"\">Informazioni GAIA</a>"));
    ((TextView) v.findViewById(R.id.about_gaia)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Internet("https://gaia.cri.it/?p=public.about");
        }
    });
    //portale sviluppo mobile
    ((TextView) v.findViewById(R.id.about_gaia_mobile))
            .setText(Html.fromHtml("<a href=\"\">Codice Sorgente Gaia Mobile</a>"));
    ((TextView) v.findViewById(R.id.about_gaia_mobile)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Internet("https://github.com/CroceRossaItaliana/gaia-android");
        }
    });
    //infomrazione dati
    ((TextView) v.findViewById(R.id.about_gaia_privacy))
            .setText(Html.fromHtml("<a href=\"\">Informazioni Gestione Dati</a>"));
    ((TextView) v.findViewById(R.id.about_gaia_privacy)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Internet("https://gaia.cri.it/?p=public.privacy");
        }
    });

    //((WebView)v.findViewById(R.id.about_info))//.setClickable(true);;   
    return v;
}

From source file:jp.mydns.sys1yagi.android.printingframeworksample.html.HtmlPrintActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_html_print);

    final WebView webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override//  w ww.  ja v a2  s. c  o  m
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
    webView.loadUrl("http://visible-true.blogspot.jp/");

    findViewById(R.id.print_button).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            printHtml(webView.getTitle() + ".pdf", webView);
        }
    });
}

From source file:org.feedhenry.saml.fragments.WebViewFragment.java

@Nullable
@Override//from  w w  w. j a va 2  s .  c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    String ssoStringURL = getArguments().getString(URL);

    View view = View.inflate(getActivity(), R.layout.fragment_webview, null);

    WebView webView = (WebView) view.findViewById(R.id.ssoWebView);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // It' logged
            if (url.endsWith("login/ok")) {
                SAMLActivity activity = (SAMLActivity) getActivity();
                activity.retrieveUserData();
            }
        }
    });
    webView.loadUrl(ssoStringURL);

    return view;
}

From source file:at.alladin.rmbt.android.util.RMBTTermsFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    activity = getActivity();//from  w  ww  .  j av  a2 s  . co  m

    webview = new WebView(activity);

    /* JavaScript must be enabled if you want it to work, obviously */
    // webview.getSettings().setJavaScriptEnabled(true);

    webview.getSettings().setSupportZoom(true);
    webview.getSettings().setBuiltInZoomControls(true);

    webview.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(final WebView view, final int errorCode, final String description,
                final String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            webview.loadUrl("file:///android_res/raw/error.html");
        }
    });

    webview.loadUrl(this.getString(R.string.url_terms));

    return webview;
}

From source file:com.example.health_connect.MySampleFragment3.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mView = inflater.inflate(R.layout.sample_fragment3, container, false);
    Parse.initialize(mView.getContext(), "e0FVFRBMAWJi5shg4XF8zL3SIuRwDIufww3338so",
            "toTJmlHTEF43u7PoAFT4fedwqfhoWiSajj1Se7FT");

    ParseUser currentUser = ParseUser.getCurrentUser();
    Log.d("Check", currentUser.getObjectId());
    ImageView birthdaypic = (ImageView) mView.findViewById(R.id.imageView2);
    TextView wish = (TextView) mView.findViewById(R.id.textView23);
    TextView hbday = (TextView) mView.findViewById(R.id.textView24);

    WebView webview = (WebView) mView.findViewById(R.id.pic);
    webview.setWebViewClient(new WebViewClient() {
        @Override//  ww w .j a  v  a2s . c o m
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.i("WEB_VIEW_TEST", "error code: " + errorCode + " " + description);
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    });
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);
    String u_r_l;
    if (currentUser.getString("image_flag").equalsIgnoreCase("1")) {
        u_r_l = "http://cdn.filter.to/100x100/http://s3-ap-southeast-1.amazonaws.com/hconnect/"
                + currentUser.getObjectId();
    } else {
        u_r_l = "http://cdn.filter.to/100x100/cdn1.iconfinder.com/data/icons/PRACTIKA/256/user.png";
    }

    webview.loadUrl(u_r_l);

    String date_of_birth = currentUser.getString("Dob");

    Calendar c = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    String formattedDate = df.format(c.getTime());
    //Log.d("Check",formattedDate);
    String str[] = { "Every patient carries her or his own doctor inside.", "Laughter is the best medicine",
            "The art of medicine consists in amusing the patient while nature cures the disease.",
            "Health is wealth", "My health is good,it's my age that's bad.",
            "A healthy body is a guest-chamber for the soul; a sick body is a prison.",
            "Fitness:If it came in a bottle,everybody would have a good body.",
            "Ypu don't get ulcers form what you eat,but from what's eating you.",
            "Those who don't find time for exercise will have to find time for illness.",
            "Sickness comes on horseback and departs on foot.",
            "Health and appetite impart the sweetness to sugar,bread and meat.",
            "Health is not valued till sickness comes.", "Health is not simply the absence of sickness.",
            "To eat is a necessity,but to eat intelligently is an art.",
            "Let food be the medicine,thy medicine shall be thy food.", "Food is fuel,choose wisely.",
            "Health and intellect are the two blessings of life.", "The greatest wealth is health.",
            "Think positive and focus on gratitude.", "Get a good night's sleep.", "Use food over supplements.",
            "Eat 5 servings of fruits and veggies a day.", "Big idea: Be happy :)",
            "Drink water instead of surgery drinks.", "Swap big serves for smaller ones.",
            "Park the car and walk the rest of the way.",
            "No disease that can be treated by diet should be treated with any other means.",
            "Your body hears everything your mind says/",
            "Take care of your body. It's the only place you have to live.",
            "Every human being is the author of his own health or disease." };
    Random r = new Random();
    int High = 30; // 30 excluded
    int Low = 0;
    int random_number = r.nextInt(High - Low) + Low;

    if ((formattedDate.substring(0, 2).equalsIgnoreCase(date_of_birth.substring(0, 2)))
            && (formattedDate.substring(3, 5).equalsIgnoreCase(date_of_birth.substring(3, 5))))
    //   if(d1==d2 && m1==m2)
    {

    } else {
        //   Log.d("Check", d1);
        birthdaypic.setImageDrawable(null);
        wish.setText(null);
        hbday.setText(null);
        wish.setText(str[random_number]);
        //wish.setVisibility(View.GONE);
        hbday.setVisibility(View.GONE);
    }

    TextView a_name = (TextView) mView.findViewById(R.id.pdob);
    TextView a_eid = (TextView) mView.findViewById(R.id.textView8);
    TextView a_add = (TextView) mView.findViewById(R.id.textView10);
    TextView a_dob = (TextView) mView.findViewById(R.id.textView12);
    TextView a_lno = (TextView) mView.findViewById(R.id.textView14);
    TextView a_year = (TextView) mView.findViewById(R.id.textView16);
    TextView a_mschool = (TextView) mView.findViewById(R.id.textView18);
    TextView a_spec = (TextView) mView.findViewById(R.id.textView20);
    TextView a_deg = (TextView) mView.findViewById(R.id.textView22);
    a_name.setText(currentUser.getUsername());
    a_deg.setText(currentUser.getString("Degree"));
    a_dob.setText(currentUser.getString("Dob"));
    a_spec.setText(currentUser.getString("Primary_speciality"));
    a_mschool.setText(currentUser.getString("Medical_School"));
    a_add.setText(currentUser.getString("Address"));
    a_year.setText(currentUser.getString("Start_Practice"));
    a_eid.setText(currentUser.getEmail());
    a_lno.setText(currentUser.getString("LicenseNo"));

    return mView;
}

From source file:com.wordpress.jftreading.BaseFragmentWebView.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    fragmentView = inflater.inflate(R.layout.webview_fragment, container, false);
    browser = (WebView) fragmentView.findViewById(R.id.webkit);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.setWebViewClient(new WebViewClient() {
        @Override/*from  w w  w  .  ja  v a2  s . co m*/
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!networkIsUp() && !offlinePage) {
                view.loadUrl(getErrorPage());
                return true;
            }
            if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
                return false;
            }
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    });
    browser.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
            return super.onJsConfirm(view, url, message, result);
        }
    });
    browser.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                WebView webView = (WebView) v;

                switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    if (webView.canGoBack()) {
                        webView.goBack();
                        return true;
                    }
                    break;
                }
            }
            return false;
        }
    });
    browser.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    browser.addJavascriptInterface(new MyJavascriptInterface(), "Android");
    browser.loadUrl(linkSelector());
    return fragmentView;
}

From source file:jlelse.simplewebwrapper.SimpleWebWrapperActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // FAB/*from  w  w w  .  ja v a2 s  .c om*/
    enableFabChanges();

    //WebView
    webView = new WebView(this);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (isOnlyOwnPagesAllowed()) {
                if (Uri.parse(url).getHost().equals(Uri.parse(getStartUrl()).getHost())) {
                    loadUrl(url);
                    return false;
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(intent);
                return true;
            } else {
                return false;
            }
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }
    });
    addContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
}

From source file:net.kourlas.voipms_sms.activities.HelpActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.help);/* www . ja va  2s  .co  m*/

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation));
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    WebView browser = (WebView) findViewById(R.id.web_view);
    browser.loadUrl(getString(R.string.help_url));
    browser.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
                view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            } else {
                return false;
            }
        }
    });
}

From source file:net.kourlas.voipms_sms.activities.CreditsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.credits);/*from www.  j  a  va  2s. co m*/

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation));
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    WebView browser = (WebView) findViewById(R.id.web_view);
    browser.loadUrl(getString(R.string.credits_url));
    browser.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
                view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            } else {
                return false;
            }
        }
    });
}