Example usage for android.webkit WebView WebView

List of usage examples for android.webkit WebView WebView

Introduction

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

Prototype

public WebView(Context context) 

Source Link

Document

Constructs a new WebView with an Activity Context object.

Usage

From source file:com.heliopause.nope.fragments.AboutFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.about_list);

    WebView mWebView = new WebView(getPreferenceScreen().getContext());
    mWebView.loadUrl("file:///android_asset/licenses/licenses_html");

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setCancelable(true).setView(mWebView).setTitle(R.string.license_title);
    mTextDlg = builder.create();// w w  w.ja  va  2  s.  c om
    mTextDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {

        public void onDismiss(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    // Setup pref items
    Preference mRateAppPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_RATE_APP);
    if (mRateAppPref != null) {
        mRateAppPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {

                try {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=" + getActivity().getPackageName())));
                } catch (android.content.ActivityNotFoundException anfe) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                            "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
                }
                return true;
            }

        });
    }
    Preference mContactDevPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_CONTACT_DEV);
    if (mContactDevPref != null) {
        mContactDevPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri data = Uri.parse("mailto:" + getActivity().getString(R.string.developer_email));
                intent.setData(data);
                startActivity(intent);
                return true;
            }
        });
    }
    Preference mReportBugPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_REPORT_BUG);
    if (mReportBugPref != null) {
        mReportBugPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(getActivity().getString(R.string.report_bug_url)));
                startActivity(intent);
                return true;
            }
        });
    }
    Preference mOpenSourcePref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_OPEN_SOURCE);
    if (mOpenSourcePref != null) {
        mOpenSourcePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                mTextDlg.show();
                return true;
            }
        });
    }
    mVersionPref = getPreferenceScreen().findPreference(Constants.ABOUT_KEY_VERSION);

}

From source file:com.google.samples.apps.ledtoggler.LicenseDialog.java

@NonNull
@Override/*from   www  .ja v a2 s  .  c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/licenses.html");

    return new AlertDialog.Builder(getActivity()).setView(webView)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:org.gots.ui.WebViewActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    WebView mWebView = new WebView(getActivity());
    mWebView.setWebViewClient(new HelloWebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);

    Bundle bundle = this.getArguments();
    String url = bundle.getString("org.gots.seed.url");

    mWebView.loadUrl(url);//  ww  w.  j  a v  a 2  s .c  o m

    pd = ProgressDialog.show(getActivity(), "", getResources().getString(R.string.gots_loading), true);
    pd.setCanceledOnTouchOutside(true);
    return mWebView;
}

From source file:com.jio.mhood.services.api.settings.LicensesFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//from  ww w.ja  v a2 s. c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_licenses, container, false);

    if (mWebView == null) {
        mWebView = new WebView(view.getContext());
        mWebView.setLayoutParams(
                new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.setBackgroundColor(0);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setPluginState(PluginState.ON_DEMAND);
        webSettings.setPluginState(PluginState.ON);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setUseWideViewPort(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            webSettings.setDisplayZoomControls(false);
        }

        mWebView.loadUrl(URL);
    } else {
        mParent.removeView(mWebView);
    }
    mParent = view;
    mParent.addView(mWebView);

    return mParent;
}

From source file:app.philm.in.fragments.LicencesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mWebView = new WebView(getActivity());
    mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    return mWebView;
}

From source file:com.jkenneth.droidovpn.ui.fragment.LicensesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/licenses.html");

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.open_source_licenses).setView(webView)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();//from w w w.ja v  a 2 s . c om
                }
            }).create();
}

From source file:com.google.android.apps.gutenberg.LicensesFragment.java

@NonNull
@Override/*  www .  j a  v a  2  s.  com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!TextUtils.isEmpty(url) && Patterns.WEB_URL.matcher(url).matches()) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            } else {
                return false;
            }
        }
    });
    webView.loadUrl("file:///android_asset/licenses.html");
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.licenses).setView(webView)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.leinardi.ubuntucountdownwidget.ui.dialogs.OpenSourceLicensesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.loadUrl(LICENSES_PATH);//from  w ww.  j a  va 2  s  .  c o m

    return new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogTheme)
            .setTitle(R.string.open_source_licenses).setView(webView)
            .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                }
            }).create();
}

From source file:applications.kantedal.hejablvitt.fragments.WebViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mWebView != null) {
        mWebView.destroy();//  w w  w.j  a va  2 s . c  o  m
    }
    mWebView = new WebView(getActivity());
    mWebView.getSettings().setBuiltInZoomControls(true);
    mIsWebViewAvailable = true;
    return mWebView;
}

From source file:com.bignerdranch.android.fragmentbasics.ArticleFragment.java

/**
 * Sets up the UI. It consists if a single WebView.
 *//*from   w ww  . j  a  v  a  2 s  . com*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mWebView = new WebView(getActivity());
    loadWebView();
    return mWebView;
}