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.mytwitter.activity.LicensesDialogFragment.java

@NonNull
@Override/*from  w  w w  .j  a  v a 2 s .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView view = (WebView) LayoutInflater.from(getActivity()).inflate(R.layout.dialog_licenses, null);
    view.loadUrl("file:///android_asset/open_source_licenses.html");
    return new AlertDialog.Builder(getActivity(), R.style.Theme_AppCompat_Light_Dialog_Alert)
            .setTitle("Open Source Licenses").setView(view).setPositiveButton(android.R.string.ok, null)
            .create();
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.credits);/* w w w.j  a  va  2s.c o  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;
            }
        }
    });
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.help);//from   w  ww  .  ja  v a 2 s.  c o  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:im.neon.util.VectorUtils.java

/**
 * Open a webview above the current activity.
 *
 * @param context the application context
 * @param url     the url to open//www . j a  va  2  s .  c  om
 */
private static void displayInWebview(final Context context, String url) {
    AlertDialog.Builder alert = new AlertDialog.Builder(context);

    WebView wv = new WebView(context);
    wv.loadUrl(url);
    wv.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);

            return true;
        }
    });

    alert.setView(wv);
    alert.setPositiveButton(android.R.string.ok, null);
    alert.show();
}

From source file:com.kubotaku.android.code4kyoto5374.fragments.OpenSourceLicenseDialog.java

private void setup() {
    View view = getView();//from w w w. j a  v a2s  .c  o m

    final WebView webView = (WebView) view.findViewById(R.id.license_web_view);
    webView.loadUrl("file:///android_asset/open_source_license.html");
}

From source file:org.bcsphere.components.BCWebViewClient.java

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

From source file:org.ado.minesync.gui.FaqActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_faq);
    final WebView webView = (WebView) findViewById(R.id.webViewFaq);
    webView.loadUrl(getFaqLocalizeUrl());
}

From source file:se.eliga.aves.AboutFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    WebView webView = (WebView) getView().findViewById(R.id.about_text);
    webView.loadUrl("file:///android_asset/about.html");
    webView.setBackgroundColor(0x00FFFFFF);
    webView.setVisibility(View.VISIBLE);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    webView.addJavascriptInterface(/*from   ww  w. ja va 2 s . c  o  m*/
            new AboutJSObject(getVersion(), BuildConfig.BUILDTIME, BuildConfig.BUILDTYPE), "AboutData");
}

From source file:de.schildbach.litecoinwallet.ui.HelpDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String page = args.getString(KEY_PAGE);

    final WebView webView = new WebView(activity);
    webView.loadUrl("file:///android_asset/" + page + languagePrefix() + ".html");

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(webView);/*from w  ww  .  j  a  v a 2 s.  c  o m*/
    dialog.setCanceledOnTouchOutside(true);

    return dialog;
}

From source file:com.cerema.cloud2.ui.dialog.ChangelogDialog.java

/**
 * {@inheritDoc}//from   ww  w  .  j a  v  a2 s .  co m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    /// load the custom view to insert in the dialog, between title and 
    WebView webview = new WebView(getActivity());
    webview.loadUrl(
            "file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");

    /// build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId())
            //.setTitle(R.string.whats_new)
            .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();

    dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
    return dialog;
}