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.yoavst.quickapps.news.LoginActivity.java

@AfterInject
void init() {/*from w w  w .ja  va  2s.c  o  m*/
    String url = mManager.getService().getAuthorizationUrl(EMPTY_TOKEN);
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setMessage(getString(R.string.loading));
    WebView webView = createWebView(this);
    setContentView(webView);
    webView.loadUrl(url);
}

From source file:com.vixir.finalproject.perfectday.fragment.MoreInfoFragment.java

@OnClick(R.id.about)
public void onClickAbout() {
    WebView view = (WebView) LayoutInflater.from(getContext()).inflate(R.layout.dialog_licenses, null);
    view.loadUrl("file:///android_asset/licence.html");
    new AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Light_Dialog_Alert)
            .setTitle(getString(R.string.action_licenses)).setView(view)
            .setPositiveButton(android.R.string.ok, null).show();
}

From source file:br.com.frs.foodrestrictions.AboutUs.java

@SuppressLint("SetTextI18n")
@Override/* w ww . j a v a  2 s  .  c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.activity_about_us, container, false);

    TextView appVersion = (TextView) v.findViewById(R.id.tvVersion);
    Button btChangelog = (Button) v.findViewById(R.id.about_us_bt_changelog);
    WebView webViewCredits = (WebView) v.findViewById(R.id.webViewCredits);

    btChangelog.setOnClickListener(this);

    webViewCredits.loadUrl("file:///android_asset/credits.html");

    int versionCode = BuildConfig.VERSION_CODE;

    appVersion.setText("build " + versionCode);

    return v;

}

From source file:at.alladin.rmbt.android.terms.RMBTTermsCheckFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.terms_check, container, false);

    final WebView tcWvs = (WebView) view.findViewById(R.id.termsCheckWebViewShort);
    tcWvs.loadUrl("file:///android_res/raw/terms_conditions_short.html");

    final WebView tcWvl = (WebView) view.findViewById(R.id.termsCheckWebViewLong);
    tcWvl.loadUrl("file:///android_res/raw/terms_conditions_long.html");

    final Activity activity = getActivity();
    if (!(activity instanceof RMBTMainActivity))
        firstTime = false;/* www  .j a  v  a  2 s . c om*/

    if (!firstTime)
        view.findViewById(R.id.termsButtonDecline).setVisibility(View.GONE);

    final Button buttonTermsAccept = (Button) view.findViewById(R.id.termsAcceptButton);
    buttonTermsAccept.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            ConfigHelper.setTCAccepted(getActivity(), true);
            if (firstTime) {
                ((RMBTMainActivity) getActivity()).checkSettings(true, null);
                final boolean wasNDTTermsNecessary = ((RMBTMainActivity) getActivity())
                        .showNdtCheckIfNecessary();
                if (!wasNDTTermsNecessary)
                    ((RMBTMainActivity) activity).initApp(false);
            } else if (followedByType != null) {
                ((RMBTTermsActivity) getActivity()).continueWorkflow();
            }
        }
    });

    final Button buttonTermsDecline = (Button) view.findViewById(R.id.termsDeclineButton);
    buttonTermsDecline.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            onBackPressed();
        }
    });

    return view;
}

From source file:cz.imakers.android.divky.SettingsActivity.java

@SuppressWarnings("deprecation")
@Override/*from w w w  . j a  va 2s  .c om*/
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    Preference restore = findPreference("pref_restore");
    Preference about = findPreference("pref_about");
    restore.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());
            builder.setTitle(R.string.restore_title).setMessage(R.string.restore_info)
                    .setIcon(android.R.drawable.ic_dialog_info).setNegativeButton(android.R.string.cancel, null)
                    .setPositiveButton(android.R.string.ok, new OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            DownloadQueue.getInstance().needRestore = true;
                            dialog.dismiss();
                            onBackPressed();
                        }
                    });
            builder.create().show();
            return true;
        }
    });
    // Get app version
    PackageManager pm = getPackageManager();
    String packageName = getPackageName();
    String versionName;
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = "N/A";
        e.printStackTrace();
    }
    about.setSummary(getResources().getString(R.string.app_name) + " ver. " + versionName);
    about.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());
            WebView webView = new WebView(preference.getContext());
            webView.loadUrl("file:///android_asset/LICENSE.html");
            builder.setView(webView).setTitle(R.string.about).setIcon(android.R.drawable.ic_dialog_info)
                    .setNeutralButton(android.R.string.ok, null).create().show();
            return true;
        }
    });
}

From source file:com.github.pennyfive.cinemafinlando.ui.fragment.OpenSourceLicensesDialogFragment.java

@NonNull
@Override/*from   w  w w.  ja  v  a  2  s .c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle(R.string.about_open_source_licenses_text);
    WebView webView = new WebView(getActivity());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    webView.getSettings().setTextZoom(60);
    webView.loadUrl("file:///android_asset/licenses.html");
    builder.setView(webView);
    return builder.create();
}

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. jav a  2s  .  c om
        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:im.neon.util.VectorUtils.java

/**
 * Display the licenses text./*from   w w  w.  j  ava 2s.  c  om*/
 */
public static void displayThirdPartyLicenses() {
    final Activity activity = VectorApp.getCurrentActivity();

    if (null != activity) {
        if (null != mMainAboutDialog) {
            if (mMainAboutDialog.isShowing() && (null != mMainAboutDialog.getOwnerActivity())) {
                try {
                    mMainAboutDialog.dismiss();
                } catch (Exception e) {
                    Log.e(LOG_TAG, "## displayThirdPartyLicenses() : " + e.getMessage());
                }
            }
            mMainAboutDialog = null;
        }

        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                WebView view = (WebView) LayoutInflater.from(activity).inflate(R.layout.dialog_licenses, null);
                view.loadUrl("file:///android_asset/open_source_licenses.html");

                View titleView = LayoutInflater.from(activity).inflate(R.layout.dialog_licenses_header, null);

                view.setScrollbarFadingEnabled(false);
                mMainAboutDialog = new AlertDialog.Builder(activity).setCustomTitle(titleView).setView(view)
                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                mMainAboutDialog = null;
                            }
                        }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                mMainAboutDialog = null;
                            }
                        }).create();

                mMainAboutDialog.show();
            }
        });
    }
}

From source file:mobisocial.bento.ebento.ui.EventListActivity.java

private void goInfo() {
    // Show Add dialog
    LayoutInflater factory = LayoutInflater.from(this);
    final View inputView = factory.inflate(R.layout.dialog_info, null);

    // WebView// www.j  a va  2s  .com
    final WebView webView = (WebView) inputView.findViewById(R.id.webview);
    webView.loadUrl("file:///android_asset/license.html");

    AlertDialog.Builder libDialog = new AlertDialog.Builder(this).setTitle(R.string.info_dialog_title)
            .setIcon(android.R.drawable.ic_dialog_info).setView(inputView).setCancelable(false)
            .setPositiveButton(R.string.info_dialog_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // 
                }
            });
    libDialog.create().show();
}

From source file:com.drisoftie.cwdroid.frag.FragBoard.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    swipeBoard = (SwipeRefreshLayout) inflater.inflate(R.layout.frag_board, container, false);
    webBoard = (WebView) swipeBoard.findViewById(R.id.web_board);
    webBoard.requestFocus(View.FOCUS_DOWN);

    webBoard.setWebViewClient(new WebViewClient() {
        @Override// w  ww.  ja va 2s  .c om
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            getArguments().putString(FragBoard.class.getName(), url);
            return true;
        }
    });

    return webBoard;
}