Example usage for android.webkit WebView loadUrl

List of usage examples for android.webkit WebView loadUrl

Introduction

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

Prototype

public void loadUrl(String url) 

Source Link

Document

Loads the given URL.

Usage

From source file:com.barcamppenang2014.tabfragment.AgendaFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.agenda, container, false);
    WebView agenda_wv = (WebView) v.findViewById(R.id.webview);
    NetworkAvailability network = new NetworkAvailability();
    if (network.isNetworkAvalaible(getActivity().getApplicationContext())) {
        agenda_wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        agenda_wv.loadUrl("http://barcamppenang.org/agenda.html");
    } else {/*from  w  w w  . j  a v a 2 s.  c  om*/
        agenda_wv.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        agenda_wv.loadUrl("http://barcamppenang.org/agenda.html");
    }

    return v;
}

From source file:com.example.locale.MainActivity.java

private void showLicenses() {
    WebView webView = new WebView(this);
    webView.loadUrl("file:///android_asset/open_source_licenses.html");
    new AlertDialog.Builder(MainActivity.this).setTitle(R.string.licenses_title).setView(webView)
            .setPositiveButton(android.R.string.ok, null).show();
}

From source file:com.dubsar_dictionary.Dubsar.FAQActivity.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from w  w w. ja  va2  s. c  om
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.faq);

    mWebView = (WebView) findViewById(R.id.faq_web_view);
    mWebView.getSettings().setJavaScriptEnabled(true);

    SharedPreferences preferences = getSharedPreferences(PreferencesActivity.DUBSAR_PREFERENCES, MODE_PRIVATE);
    String host = preferences.getString(PreferencesActivity.HTTP_PROXY_HOST, null);
    int port = preferences.getInt(PreferencesActivity.HTTP_PROXY_PORT, 0);

    if (host != null && port != 0) {
        mProxyFailed = !setProxy(mWebView, host, port);

        if (mProxyFailed) {
            String html = "<html><body style=\"background-color: #e0e0ff;\"><h1 style=\"color: #1c94c4; text-align: center; margin-top: 2ex; font: bold 18pt sans-serif\">"
                    + getString(R.string.proxy_fail) + " " + host + ":" + port + "</h1></body></html>";
            mWebView.loadData(html, "text/html", "utf-8");
            return;
        }
    }

    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        String html = "<html><body style=\"background-color: #e0e0ff;\"><h1 style=\"color: #1c94c4; text-align: center; margin-top: 2ex; font: bold 18pt sans-serif\">"
                + getString(R.string.loading_faq) + "</h1></body></html>";
        mWebView.loadData(html, "text/html", "utf-8");
        // Log.i(getString(R.string.app_name), "Initial FAQ HTML: " + html);
    }

    mWebView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        public void onPageFinished(WebView view, String url) {
            String faqUrl = getString(R.string.faq_url);
            if (!mProxyFailed && (url == null || !url.equals(faqUrl))) {
                mWebView.loadUrl(faqUrl);
            }
        }
    });
}

From source file:com.app.sniffy.MainActivity.java

public void showTerms() {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialoglayout = inflater.inflate(R.layout.terms, null);

    WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView);
    webView.loadUrl("file:///android_asset/license.html");

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Terms & Conditions");
    builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox);
                    if (checkBox.isChecked()) {

                        SharedPreferences.Editor editor = settings.edit();
                        editor.putBoolean("userconsent", true);
                        editor.commit();
                        try {
                            new GetKey(context).execute(
                                    new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId
                                            + Utils.getConfigProperty(getResources(), "securekey")));
                        } catch (URISyntaxException e1) {
                            Log.d("main activity key generate", e1.toString());
                        }//  ww  w .j  a  va 2  s.c om
                    } else {
                        showTerms();
                    }

                }
            });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.ezac.gliderlogs.FlightNotamBLXActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//from  w ww .  j  a v  a 2s.co m

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.loadUrl("http://www.notaminfo.com/belgiummap");

}

From source file:com.ezac.gliderlogs.FlightNotamNLDActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);/*from  ww w  .  j a  v a2s. c  o m*/

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.loadUrl("http://www.zweefvlieg.net/notam2014/");

}

From source file:com.ezac.gliderlogs.FlightRaspActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);/*ww  w.j a  v  a2 s .c  o m*/

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.loadUrl("http://blipmaps.nl/showblipmap.php?Param=sfctemp&Day=0&Time=1130&Lang=En&Stage=1");

}

From source file:com.poepoemyintswe.popularmovies.ui.MainFragment.java

private void showLicense() {
    WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/licenses.html");

    new android.app.AlertDialog.Builder(getActivity(), R.style.MyAlertDialogStyle)
            .setTitle(R.string.action_license).setView(webView)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();//from w  ww. java2  s.  com
                }
            }).create().show();
}

From source file:felixwiemuth.lincal.ui.HtmlDialogFragment.java

private boolean loadUrl(WebView webView, Uri uri) {
    if (uri.getScheme().equals("file")) {
        webView.loadUrl(uri.toString());
    } else if (uri.getScheme().equals("action")) {
        List<String> segments = uri.getPathSegments();
        if (segments.isEmpty()) {
            throw new RuntimeException("Error in WebView: No action name provided.");
        } else {//from w  w w .  ja  v a  2s .c om
            handleAction(segments.get(0), segments.subList(1, segments.size()));
        }
    } else {
        // If the URI is not pointing to a local file, open with an ACTION_VIEW Intent
        webView.getContext().startActivity(new Intent(Intent.ACTION_VIEW, uri));
    }
    return true; // in both cases we handle the link manually
}

From source file:de.blinkt.openvpn.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about, container, false);
    TextView ver = (TextView) v.findViewById(R.id.version);

    String version;//from w  w w .  ja v a  2 s. c  o  m
    String name = "Openvpn";
    try {
        PackageInfo packageinfo = getActivity().getPackageManager()
                .getPackageInfo(getActivity().getPackageName(), 0);
        version = packageinfo.versionName;
        name = getString(R.string.app);
    } catch (NameNotFoundException e) {
        version = "error fetching version";
    }

    ver.setText(getString(R.string.version_info, name, version));

    TextView paypal = (TextView) v.findViewById(R.id.donatestring);

    String donatetext = getActivity().getString(R.string.donatewithpaypal);
    Spanned htmltext = Html.fromHtml(donatetext);
    paypal.setText(htmltext);
    paypal.setMovementMethod(LinkMovementMethod.getInstance());
    gmsTextView = (TextView) v.findViewById(R.id.donategms);
    /* recreating view without onCreate/onDestroy cycle */

    // Disable GMS for now
    if (mService != null)
        initGooglePlayDonation();

    TextView translation = (TextView) v.findViewById(R.id.translation);

    // Don't print a text for myself
    if (getString(R.string.translationby).contains("Arne Schwabe"))
        translation.setText("");
    else
        translation.setText(R.string.translationby);

    WebView wv = (WebView) v.findViewById(R.id.webView);
    wv.loadUrl("file:///android_asset/full_licenses.html");

    return v;
}