checking internet connectivity
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1737877/how-to-determine-android-internet-connection">How to determine Android internet connection?</a>  </p>
</blockquote>



<p>i am calling  webview . i want to implement that if there is no Internet connection it should not open the activity and display the message  in Toast . Please Guide
calling point </p>

<pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id)  {
                 switch (position) {
                 case 0:     
                    Intent intent = new Intent(v.getContext(),Settings.class);
                      startActivity(intent);
                 break;

                 case 1:     
                    Intent intent1 = new Intent(v.getContext(),Web_services.class);
                      startActivity(intent1);
                 break;
</code></pre>

<p>and the webview is like this </p>

<pre><code>public class News extends menu {
    private WebView webview;
    private static final String TAG = "Main";
    private ProgressDialog progressBar;  
      Prefs myprefs = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.weblayout);
        this.myprefs = new Prefs(getApplicationContext());
        this.webview = (WebView)findViewById(R.id.MyWebview);

        WebSettings settings = webview.getSettings();
        settings.setJavaScriptEnabled(true);
        webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        webview.setBackgroundColor(Color.parseColor("#000000"));
        webview.setVerticalScrollBarEnabled(false);
        webview.setHorizontalScrollBarEnabled(false);
        final AlertDialog alertDialog = new AlertDialog.Builder(this).create();

        progressBar = ProgressDialog.show(News .this, "Please Wait", "Loading...");
        this.myprefs = new Prefs(getApplicationContext());
        webview.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                Log.i(TAG, "Processing webview url click...");
                view.loadUrl(url);
                return true;
            }

            public void onPageFinished(WebView view, String url) {
                Log.i(TAG, "Finished loading URL: " +url);
                if (progressBar.isShowing()) {
                    progressBar.dismiss();
                }
            }

            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Log.e(TAG, "Error: " + description);
                Toast.makeText(News.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
                alertDialog.setTitle("Error");
                alertDialog.setMessage(description);
                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                alertDialog.show();
            }
        });
        webview.loadUrl("");
    }

  }
</code></pre>
