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.drisoftie.cwdroid.frag.FragShoutbox.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    swipeShoutbox = (SwipeRefreshLayout) inflater.inflate(R.layout.frag_shoutbox, container, false);
    webShoutbox = (WebView) swipeShoutbox.findViewById(R.id.web_shoutbox);

    webShoutbox.setWebViewClient(new WebViewClient() {
        @Override//  w  ww  . j a v  a 2s  .c o m
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            getArguments().putString(FragShoutbox.class.getName(), url);
            return true;
        }
    });
    return webShoutbox;
}

From source file:com.centurylink.mdw.mobile.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/* ww w . j  a  va  2 s.  c om*/

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    settings = new Settings(getApplicationContext());

    webView = (WebView) findViewById(R.id.webview);
    webView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setSupportZoom(true);
    // webView.getSettings().setBuiltInZoomControls(true);
    // allow debugging with chrome dev tools
    WebView.setWebContentsDebuggingEnabled(true);

    // do not cache in debug
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.getSettings().setAppCacheEnabled(false);
    webView.clearCache(true);

}

From source file:com.abcvoipsip.ui.help.Faq.java

public View getCustomView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.faq, container, false);
    WebView webView = (WebView) v.findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new FaqWebViewClient(v));
    webView.loadUrl(FAQ_URL);
    return v;//from w ww . j a v a2s.  com
}

From source file:de.t_animal.journeyapp.InformationFragment.java

private void showHTMLPopup(View v) {
    String title;/*  ww w  .  j  a  va2  s .  com*/
    String url;

    if (v.getId() == R.id.info_acknowledgement) {
        title = "Acknowledgements";
        url = "file:///android_asset/acknowledgements.html";
    } else {
        title = "License";
        url = "file:///android_asset/license.html";
    }

    WebView wv = new WebView(getActivity());
    wv.loadUrl(url);

    new AlertDialog.Builder(getActivity()).setTitle(title).setView(wv)
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            }).show();

}

From source file:com.kanazawaevent.view.activity.MainActivity.java

private void showLicenceDialog(int titleId, String url) {
    WebView view = (WebView) LayoutInflater.from(this).inflate(R.layout.dialog_licence, null);
    view.loadUrl(url);
    AlertDialog dialog = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Light_Dialog_Alert)
            .setTitle(titleId).setView(view).setPositiveButton(android.R.string.ok, null).show();
}

From source file:es.glasspixel.wlanaudit.activities.AboutActivity.java

/**
 * @see android.app.Activity#onStart//from w w  w  .j a  v  a 2s  .  c  om
 */
@Override
protected void onStart() {
    super.onStart();
    mVersionValueLabel.setText(getVersion());
    mReleaseValueLabel.setText(String.valueOf(getRelease()));
    mOssLicensesButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder alert = new AlertDialog.Builder(AboutActivity.this);

            alert.setTitle(getText(R.string.oss_licenses_dialog_title));
            WebView wv = new WebView(AboutActivity.this);

            wv.loadUrl("file:///android_asset/licenses.html");
            alert.setView(wv);
            alert.show();
        }
    });
    mFacebookButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://www.facebook.com/wlanaudit"));
            startActivity(browserIntent);
        }
    });
    mTwitterButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://twitter.com/#!/TitoXamps"));
            startActivity(browserIntent);
        }
    });
    mGplusButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://plus.google.com/b/113060827862322417267/113060827862322417267"));
            startActivity(browserIntent);
        }
    });
}

From source file:it.evilsocket.dsploit.plugins.mitm.hijacker.HijackerWebView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    setTitle(System.getCurrentTarget() + " > MITM > Session Hijacker");
    setContentView(R.layout.plugin_mitm_hijacker_webview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setSupportProgressBarIndeterminateVisibility(false);

    mWebView = (WebView) findViewById(R.id.webView);
    mSettings = mWebView.getSettings();//from ww w. j  a v a  2 s .c o  m

    mSettings.setJavaScriptEnabled(true);
    mSettings.setBuiltInZoomControls(true);
    mSettings.setAppCacheEnabled(false);
    mSettings.setUserAgentString(DEFAULT_USER_AGENT);

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

    mWebView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (mWebView != null)
                getSupportActionBar().setSubtitle(mWebView.getUrl());

            setSupportProgressBarIndeterminateVisibility(true);
            // Normalize our progress along the progress bar's scale
            int mmprogress = (Window.PROGRESS_END - Window.PROGRESS_START) / 100 * progress;
            setSupportProgress(mmprogress);

            if (progress == 100)
                setSupportProgressBarIndeterminateVisibility(false);
        }
    });

    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeAllCookie();

    Session session = (Session) System.getCustomData();
    if (session != null) {
        String domain = null, rawcookie = null;

        for (BasicClientCookie cookie : session.mCookies.values()) {
            domain = cookie.getDomain();
            rawcookie = cookie.getName() + "=" + cookie.getValue() + "; domain=" + domain + "; path=/"
                    + (session.mHTTPS ? ";secure" : "");

            CookieManager.getInstance().setCookie(domain, rawcookie);
        }

        CookieSyncManager.getInstance().sync();

        if (session.mUserAgent != null && session.mUserAgent.isEmpty() == false)
            mSettings.setUserAgentString(session.mUserAgent);

        mWebView.loadUrl((session.mHTTPS ? "https" : "http") + "://www." + domain);
    }
}

From source file:de.nico.asura.activities.AuthWebView1.java

private void openWebView() {
    setContentView(R.layout.webview);/*from   w  ww  .j  ava  2s. c o m*/
    WebView webView = (WebView) findViewById(R.id.webView_main);
    webView.setWebViewClient(new MyWebViewClient());
    webView.loadUrl(getString(R.string.menu_AuthWeb_1_url));
    webView.getSettings().setBuiltInZoomControls(true);
}

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 . j  ava 2 s.  c  o m*/
    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.sim2dial.dialer.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.webaddres, container, false);
    TextView tv = (TextView) view.findViewById(R.id.textView1);
    tv.setText("About Us");
    WebView web = (WebView) view.findViewById(R.id.webView1);
    if (getArguments() != null) {
        String abouturl = getArguments().getString("about");
        web.getSettings().setJavaScriptEnabled(true);
        web.loadUrl(abouturl);
    }//from  w  w  w.ja  v  a 2 s.  c o m
    return view;
}